From abd395d8bde5a0a26fcee194af594cf67cb56df2 Mon Sep 17 00:00:00 2001 From: Layne Date: Mon, 8 Mar 2021 12:40:41 -0500 Subject: [PATCH 01/94] update navigator --- .../com/eu/habbo/habbohotel/navigation/NavigatorManager.java | 2 +- .../eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java index 929456b9..5745834d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -46,7 +46,7 @@ public class NavigatorManager { synchronized (this.publicCategories) { this.publicCategories.clear(); - try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publiccats WHERE visible = '1'")) { + try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publiccats WHERE visible = '1' ORDER BY order_num DESC")) { while (set.next()) { this.publicCategories.put(set.getInt("id"), new NavigatorPublicCategory(set)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java index 4ab8c3bd..40ae72b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java @@ -25,7 +25,7 @@ public class NavigatorPublicFilter extends NavigatorFilter { for (NavigatorPublicCategory category : Emulator.getGameEnvironment().getNavigatorManager().publicCategories.values()) { if (!category.rooms.isEmpty()) { - resultLists.add(new SearchResultList(i, "", category.name, SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.name, category.image), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.name), category.rooms, true, showInvisible, DisplayOrder.ACTIVITY, category.order)); + resultLists.add(new SearchResultList(i, "", category.name, SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.name, category.image), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.name), category.rooms, true, showInvisible, DisplayOrder.ORDER_NUM, category.order)); i++; } } From 4ab008f3c6b128f5b987f86192fefce4332a2cec Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Wed, 26 May 2021 06:29:52 +0000 Subject: [PATCH 02/94] Consistency... --- src/main/java/com/eu/habbo/Emulator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 33a46886..97fe313a 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -170,7 +170,7 @@ public final class Emulator { Emulator.timeStarted = getIntUnixTimestamp(); if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) { - LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to {} to possibly increase performance.", + LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to ({}) to possibly increase performance.", Emulator.getConfig().getInt("runtime.threads"), Runtime.getRuntime().availableProcessors() * 2); } @@ -499,4 +499,4 @@ public final class Emulator { public int getRoomCount() { return gameEnvironment.getRoomManager().getActiveRooms().size(); } -} \ No newline at end of file +} From 40793258b6b3cb9eff9521bcefa992b313438713 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Mon, 30 Aug 2021 15:46:15 +0200 Subject: [PATCH 03/94] Custom configs added for wired (multiple users teleporting at the same time) Custom place/rotate under user setting Custom walk on furni if placed/rotated under user setting --- .../items/interactions/InteractionWired.java | 36 ++++++++++++++++-- .../com/eu/habbo/habbohotel/rooms/Room.java | 38 +++++++++++++++---- .../habbo/habbohotel/wired/WiredHandler.java | 9 +++-- 3 files changed, 69 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index c19b1ec9..8a8f1e7f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -4,9 +4,9 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer; +import gnu.trove.map.hash.TLongLongHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,6 +18,7 @@ import java.sql.SQLException; public abstract class InteractionWired extends InteractionDefault { private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class); private long cooldown; + private TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -69,10 +70,16 @@ public abstract class InteractionWired extends InteractionDefault { public abstract void onPickUp(); public void activateBox(Room room) { - this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); - room.sendComposer(new ItemStateComposer(this).compose()); + this.activateBox(room, (RoomUnit)null, 0L); } + public void activateBox(Room room, RoomUnit roomUnit, long millis) { + this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); + room.sendComposer(new ItemStateComposer(this).compose()); + if (roomUnit != null) { + this.addUserExecutionCache(roomUnit.getId(), millis); + } + } protected long requiredCooldown() { return 50L; @@ -96,4 +103,27 @@ public abstract class InteractionWired extends InteractionDefault { public boolean isUsable() { return true; } + + public boolean userCanExecute(int roomUnitId, long timestamp) { + if (roomUnitId == -1) { + return true; + } else { + if (this.userExecutionCache.containsKey((long)roomUnitId)) { + long lastTimestamp = this.userExecutionCache.get((long)roomUnitId); + if (timestamp - lastTimestamp < 100L) { + return false; + } + } + + return true; + } + } + + public void clearUserExecutionCache() { + this.userExecutionCache.clear(); + } + + public void addUserExecutionCache(int roomUnitId, long timestamp) { + this.userExecutionCache.put((long)roomUnitId, 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 58321d7d..18c6cdcb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4501,9 +4501,11 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); for (RoomTile t : occupiedTiles) { if(t.state == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE; - if (checkForUnits && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; - if (checkForUnits && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; - if (checkForUnits && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) { + if (checkForUnits && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; + if (checkForUnits && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; + if (checkForUnits && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + } } List>> tileFurniList = new ArrayList<>(); @@ -4610,10 +4612,14 @@ public class Room implements Comparable, ISerialize, Runnable { } public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) { - return moveFurniTo(item, tile, rotation, actor, true); + return moveFurniTo(item, tile, rotation, actor, true, true); } public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) { + return moveFurniTo(item, tile, rotation, actor, sendUpdates, true); + } + + public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) { RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY()); boolean pluginHelper = false; @@ -4631,6 +4637,7 @@ public class Room implements Comparable, ISerialize, Runnable { //Check if can be placed at new position THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); + THashSet newOccupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); HabboItem topItem = this.getTopItemAt(occupiedTiles, null); @@ -4640,9 +4647,14 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) return FurnitureMovementError.CANT_STACK; - if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; - if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; - if (!magicTile && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + + if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) { + if (checkForUnits) { + if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; + if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; + if (!magicTile && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + } + } } } @@ -4746,6 +4758,18 @@ public class Room implements Comparable, ISerialize, Runnable { ); this.updateBotsAt(t.x, t.y); } + if(Emulator.getConfig().getBoolean("wired.place.under", false)) { + for(RoomTile t : newOccupiedTiles) { + for(Habbo h : this.getHabbosAt(t.x, t.y)) { + try { + item.onWalkOn(h.getRoomUnit(), this, null); + } + catch(Exception e) { + + } + } + } + } return FurnitureMovementError.NONE; } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 9f27ad78..2cbc6d09 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -160,8 +160,9 @@ public class WiredHandler { public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff, final THashSet effectsToExecute) { long millis = System.currentTimeMillis(); - if (Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) { - trigger.activateBox(room); + int roomUnitId = roomUnit != null ? roomUnit.getId() : -1; + if (Emulator.isReady && ((Emulator.getConfig().getBoolean("wired.custom.enabled", false) && (trigger.canExecute(millis) || roomUnitId > -1) && trigger.userCanExecute(roomUnitId, millis)) || (!Emulator.getConfig().getBoolean("wired.custom.enabled", false) && trigger.canExecute(millis))) && trigger.execute(roomUnit, room, stuff)) { + trigger.activateBox(room, roomUnit, millis); THashSet conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY()); THashSet effects = room.getRoomSpecialTypes().getEffects(trigger.getX(), trigger.getY()); @@ -193,7 +194,7 @@ public class WiredHandler { THashSet extras = room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY()); for (InteractionWiredExtra extra : extras) { - extra.activateBox(room); + extra.activateBox(room, roomUnit, millis); } List effectList = new ArrayList<>(effects); @@ -241,7 +242,7 @@ public class WiredHandler { LOGGER.error("Caught exception", e); } - effect.activateBox(room); + effect.activateBox(room, roomUnit, millis); } }, effect.getDelay() * 500); } From f77693d2e5427766c6540c22e514f9b151c36167 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 1 Sep 2021 14:39:03 +0000 Subject: [PATCH 04/94] Fix offline friendrequests --- .../habbo/habbohotel/messenger/Messenger.java | 5 + .../habbohotel/messenger/MessengerBuddy.java | 3 +- .../incoming/friends/FriendRequestEvent.java | 96 +++++++++---------- 3 files changed, 55 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java index db3c357c..b1d3eb25 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -65,6 +65,11 @@ public class Messenger { return users; } + /** + * @deprecated + * This method is no longer used and is only kept to avoid breaking any plugins + */ + @Deprecated public static boolean canFriendRequest(Habbo habbo, String friend) { Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(friend); HabboInfo habboInfo; diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index 4a292b87..65487f3f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -33,7 +33,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.id = set.getInt("id"); this.username = set.getString("username"); this.gender = HabboGender.valueOf(set.getString("gender")); - this.online = Integer.valueOf(set.getString("online")); + this.online = set.getInt("online"); this.motto = set.getString("motto"); this.look = set.getString("look"); this.relation = (short) set.getInt("relation"); @@ -58,6 +58,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.look = set.getString("look"); this.relation = 0; this.userOne = 0; + this.online = set.getInt("online"); } catch (SQLException e) { LOGGER.error("Caught SQL exception", e); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java index 758ca1b4..95b363d7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java @@ -23,70 +23,70 @@ public class FriendRequestEvent extends MessageHandler { @Override public void handle() throws Exception { String username = this.packet.readString(); - Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(username); - if (habbo.getHabboInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) { + if (this.client == null || username == null || username.isEmpty()) return; - } - if (Emulator.getPluginManager().fireEvent(new UserRequestFriendshipEvent(this.client.getHabbo(), username, habbo)).isCancelled()) { - this.client.sendResponse(new FriendRequestErrorComposer(2)); - return; - } + // TargetHabbo can be null if the Habbo is not online or when the Habbo doesn't exist + Habbo targetHabbo = Emulator.getGameServer().getGameClientManager().getHabbo(username); - int id = 0; - boolean allowFriendRequests = true; - - FriendRequest friendRequest = this.client.getHabbo().getMessenger().findFriendRequest(username); - if (friendRequest != null) { - this.client.getHabbo().getMessenger().acceptFriendRequest(friendRequest.getId(), this.client.getHabbo().getHabboInfo().getId()); - return; - } - - if (!Messenger.canFriendRequest(this.client.getHabbo(), username)) { - this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_FOUND)); - return; - } - - if (habbo == null) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users_settings.block_friendrequests, users.id FROM users INNER JOIN users_settings ON users.id = users_settings.user_id WHERE username = ? LIMIT 1")) { + // If the Habbo is null, we try to get the Habbo from the database. + // If the Habbo is still null, the Habbo doesn't exist. + if (targetHabbo == null) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.*, users_settings.block_friendrequests FROM users INNER JOIN users_settings ON users.id = users_settings.user_id WHERE username = ? LIMIT 1")) { statement.setString(1, username); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - id = set.getInt("id"); - allowFriendRequests = set.getString("block_friendrequests").equalsIgnoreCase("0"); + targetHabbo = new Habbo(set); } } } catch (SQLException e) { LOGGER.error("Caught SQL exception", e); return; } - } else { - id = habbo.getHabboInfo().getId(); - allowFriendRequests = !habbo.getHabboStats().blockFriendRequests; - if (allowFriendRequests) - habbo.getClient().sendResponse(new FriendRequestComposer(this.client.getHabbo())); } - if (id != 0) { - if (!allowFriendRequests) { - this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_ACCEPTING_REQUESTS)); - return; - } - - if (this.client.getHabbo().getMessenger().getFriends().values().size() >= this.client.getHabbo().getHabboStats().maxFriends && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { - this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_OWN_FULL)); - return; - } - - if (habbo.getMessenger().getFriends().values().size() >= habbo.getHabboStats().maxFriends && !habbo.hasPermission("acc_infinite_friends")) { - this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_TARGET_FULL)); - return; - } - - Messenger.makeFriendRequest(this.client.getHabbo().getHabboInfo().getId(), id); - } else { + if (targetHabbo == null) { this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_FOUND)); + return; } + + int targetId = targetHabbo.getHabboInfo().getId(); + boolean targetBlocksFriendRequests = targetHabbo.getHabboStats().blockFriendRequests; + + // Making friends with yourself would be very pathetic, we try to avoid that + if (targetId == this.client.getHabbo().getHabboInfo().getId()) + return; + + // Target Habbo exists + // Check if Habbo is accepting friend requests + if (targetBlocksFriendRequests) { + this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_ACCEPTING_REQUESTS)); + return; + } + + // You can only have x friends + if (this.client.getHabbo().getMessenger().getFriends().values().size() >= this.client.getHabbo().getHabboStats().maxFriends && !this.client.getHabbo().hasPermission("acc_infinite_friends")) { + this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_OWN_FULL)); + return; + } + + // Check if targets friendlist is full + if (targetHabbo.getMessenger().getFriends().values().size() >= targetHabbo.getHabboStats().maxFriends && !targetHabbo.hasPermission("acc_infinite_friends")) { + this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_TARGET_FULL)); + return; + } + + // Allow plugins to cancel the request + if (Emulator.getPluginManager().fireEvent(new UserRequestFriendshipEvent(this.client.getHabbo(), username, targetHabbo)).isCancelled()) { + this.client.sendResponse(new FriendRequestErrorComposer(2)); + return; + } + + if(targetHabbo.isOnline()) { + targetHabbo.getClient().sendResponse(new FriendRequestComposer(this.client.getHabbo())); + } + + Messenger.makeFriendRequest(this.client.getHabbo().getHabboInfo().getId(), targetId); } } From 9acc3f93599d217d4c27b4e3eb0a74298bb2155b Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Wed, 1 Sep 2021 17:36:32 +0200 Subject: [PATCH 05/94] Fix text on Stalk Command (by Snaiker) And some emulator_settings for the previous commit --- sqlupdates/3_0_0 to 3_0_1.sql | 4 ++++ .../java/com/eu/habbo/habbohotel/commands/StalkCommand.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 sqlupdates/3_0_0 to 3_0_1.sql diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql new file mode 100644 index 00000000..674b2097 --- /dev/null +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -0,0 +1,4 @@ +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.place.under', '0'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.custom.enabled', '0'); + +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk.forgot_username', 'Specify the username of the Habbo you want to follow!'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java index 31312dd7..de6bde54 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java @@ -43,7 +43,7 @@ public class StalkCommand extends Command { //gameClient.sendResponse(new ForwardToRoomComposer(habbo.getHabboInfo().getCurrentRoom().getId())); return true; } else { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.forgot_username"), RoomChatMessageBubbles.ALERT); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.forgot_username"), RoomChatMessageBubbles.ALERT); return true; } } From ff92e4471cae3f96af2bbb87480322dc850812c6 Mon Sep 17 00:00:00 2001 From: Thijmen Stavenuiter Date: Fri, 16 Apr 2021 23:24:38 +0200 Subject: [PATCH 06/94] Fix SQL query upon searching in Marketplace --- .../eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index 031ff4f6..9801eae2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -122,7 +122,7 @@ public class MarketPlace { query += " AND CEIL(price + (price / 100)) <= " + maxPrice; } if (search.length() > 0) { - query += " AND bi.public_name LIKE ? OR ci.catalog_name LIKE ?"; + query += " AND ( bi.public_name LIKE ? OR ci.catalog_name LIKE ? ) "; } query += " GROUP BY base_item_id, ltd_data"; From ba5a0976e314b1ecda7baea4dcf22ddc6e511e3c Mon Sep 17 00:00:00 2001 From: Thijmen Date: Wed, 1 Sep 2021 22:43:04 +0000 Subject: [PATCH 07/94] Tile error, possible scripting --- .../incoming/rooms/items/RoomPlaceItemEvent.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java index bf3842ce..8cdeb7d0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.interactions.*; +import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; @@ -78,6 +79,15 @@ public class RoomPlaceItemEvent extends MessageHandler { } RoomTile tile = room.getLayout().getTile(x, y); + + if(tile == null) + { + String userName = this.client.getHabbo().getHabboInfo().getUsername(); + int roomId = room.getId(); + ScripterManager.scripterDetected(this.client, "User [" + userName + "] tried to place a furni with itemId [" + itemId + "] at a tile which is not existing in room [" + roomId + "], tile: [" + x + "," + y + "]"); + return; + } + FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); if (!error.equals(FurnitureMovementError.NONE)) { From 6049c195d6448013068d1dcc02653773e9e40bde Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Thu, 2 Sep 2021 01:41:33 +0200 Subject: [PATCH 08/94] Reverted Wired Condition inner workings because it seemed to only give problems and nullpointers --- .../WiredConditionTriggerOnFurni.java | 24 ++----------------- 1 file changed, 2 insertions(+), 22 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 250d4751..61e3fd70 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 @@ -46,28 +46,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { } protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) { - /* - * 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles. - * 2. If a Habbo IS walking we have to check if the next tile in the walking path is one of the selected items - * */ - if (!roomUnit.isWalking()) { - THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); - return this.items.stream().anyMatch(itemsAtUser::contains); - } else { - RoomTile firstTileInPath = room.getLayout() - .findPath(roomUnit.getCurrentLocation(), roomUnit.getGoal(), roomUnit.getGoal(), roomUnit) - .peek(); - - if (firstTileInPath == null) - return false; - - return this.items - .stream() - .anyMatch(conditionItem -> conditionItem - .getOccupyingTiles(room.getLayout()) - .contains(firstTileInPath) - ); - } + THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation()); + return this.items.stream().anyMatch(itemsAtUser::contains); } @Override From 423211bc704967c9611ee3a6729489e268695b5b Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 1 Sep 2021 23:57:15 +0000 Subject: [PATCH 09/94] fixed inifnite recursion --- .../java/com/eu/habbo/habbohotel/rooms/Room.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 58321d7d..b4d11cb1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2671,6 +2671,10 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit()); } + synchronized (this.roomUnitLock) { + this.currentHabbos.remove(habbo.getHabboInfo().getId()); + } + if (sendRemovePacket && habbo.getRoomUnit() != null && !habbo.getRoomUnit().isTeleporting) { this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose()); } @@ -2687,10 +2691,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - synchronized (this.roomUnitLock) { - this.currentHabbos.remove(habbo.getHabboInfo().getId()); - } - if (habbo.getHabboInfo().getCurrentGame() != null) { if (this.getGame(habbo.getHabboInfo().getCurrentGame()) != null) { this.getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); @@ -3820,10 +3820,7 @@ public class Room implements Comparable, ISerialize, Runnable { public void sendComposer(ServerMessage message) { for (Habbo habbo : this.getHabbos()) { - if (habbo.getClient() == null) { - this.removeHabbo(habbo, true); - continue; - } + if (habbo.getClient() == null) continue; habbo.getClient().sendResponse(message); } From e76c2de94a44aeca33aeea662e6beaf3821a8f16 Mon Sep 17 00:00:00 2001 From: Raizer Date: Thu, 2 Sep 2021 00:32:33 +0000 Subject: [PATCH 10/94] COUNT() always return something, statement found would be always true. --- .../java/com/eu/habbo/messages/rcon/GiveBadge.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java b/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java index 98d63c33..4cb93feb 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveBadge.java @@ -55,16 +55,18 @@ public class GiveBadge extends RCONMessage { } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { for (String badgeCode : json.badge.split(";")) { - boolean found; + int numberOfRows = 0; try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.id = ? AND badge_code = ? LIMIT 1")) { statement.setInt(1, json.user_id); statement.setString(2, badgeCode); try (ResultSet set = statement.executeQuery()) { - found = set.next(); + if (set.next()){ + numberOfRows = set.getInt(1); + } } } - if (found) { + if (numberOfRows != 0) { this.status = RCONMessage.STATUS_ERROR; this.message += Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", username).replace("%badge%", badgeCode) + "\r"; } else { @@ -92,4 +94,4 @@ public class GiveBadge extends RCONMessage { public String badge; } -} \ No newline at end of file +} From 9386ad46635ccc716a2e010f782ecb591fd3e3e4 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Thu, 2 Sep 2021 14:59:33 +0200 Subject: [PATCH 11/94] Custom Wired small fix --- src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 2cbc6d09..1cb10037 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -230,7 +230,7 @@ public class WiredHandler { private static boolean triggerEffect(InteractionWiredEffect effect, RoomUnit roomUnit, Room room, Object[] stuff, long millis) { boolean executed = false; - if (effect != null && effect.canExecute(millis)) { + if (effect != null && (effect.canExecute(millis) || (roomUnit != null && effect.requiresTriggeringUser() && Emulator.getConfig().getBoolean("wired.custom.enabled", false) && effect.userCanExecute(roomUnit.getId(), millis)))) { executed = true; if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { Emulator.getThreading().run(() -> { From 1b82658bd38af2e7c2916b5dc3c89e93ce737020 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Fri, 3 Sep 2021 16:25:27 +0200 Subject: [PATCH 12/94] Fix trap interaction (Kitt Mustang) --- .../items/interactions/InteractionTrap.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java index 54b9baaa..cf740699 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java @@ -22,40 +22,40 @@ public class InteractionTrap extends InteractionDefault { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - super.onWalkOn(roomUnit, room, objects); + if (!this.getExtradata().equals("0")) { + Habbo habbo = room.getHabbo(roomUnit); + int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId(); + roomUnit.stopWalking(); + super.onWalkOn(roomUnit, room, objects); + int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName()); + if (delay == 0) { + Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000"); + delay = 3000; + } - if (!this.getExtradata().equals("1")) - return; + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { - int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName()); + if (habbo != null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { + room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + return; + } - if (delay == 0) { - Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000"); - delay = 3000; - } + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { + room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + return; + } - if (roomUnit != null) { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { - Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); - return; + roomUnit.setCanWalk(false); + Emulator.getThreading().run(() -> { + room.giveEffect(roomUnit, 0, -1); + roomUnit.setCanWalk(true); + room.giveEffect(roomUnit, effect, -1); + }, delay); } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); - return; - } - - - roomUnit.setCanWalk(false); - Emulator.getThreading().run(() -> { - room.giveEffect(roomUnit, 0, -1); - roomUnit.setCanWalk(true); - }, delay); } } } From 7cbc8cc162a6de27ef4ad9d7abb52fe5ed304b6b Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sat, 4 Sep 2021 03:12:37 +0200 Subject: [PATCH 13/94] Battle Banzai nullpointers and disconnect fix --- .../games/battlebanzai/BattleBanzaiGame.java | 97 ++++++++++--------- .../InteractionWiredHighscore.java | 18 +++- .../wired/effects/WiredEffectGiveScore.java | 18 +++- 3 files changed, 78 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index b2ee6dcf..c14f6408 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -203,8 +203,9 @@ public class BattleBanzaiGame extends Game { item.setExtradata((6 + winningTeam.teamColor.type) + ""); this.room.updateItemState(item); } - - Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room)); + synchronized (this.lockedTiles) { + Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room)); + } } super.onEnd(); @@ -222,7 +223,9 @@ public class BattleBanzaiGame extends Game { this.room.updateItem(tile); } } - this.lockedTiles.clear(); + synchronized (this.lockedTiles) { + this.lockedTiles.clear(); + } } @@ -249,52 +252,54 @@ public class BattleBanzaiGame extends Game { } public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill) { - if (item instanceof InteractionBattleBanzaiTile) { - if (!this.lockedTiles.containsKey(teamColor)) { - this.lockedTiles.put(teamColor, new THashSet<>()); - } - - this.lockedTiles.get(teamColor).add(item); - } - - if (habbo != null) { - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked")); - } - - if (doNotCheckFill) return; - - final int x = item.getX(); - final int y = item.getY(); - - final List> filledAreas = new ArrayList<>(); - final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor)); - - executor.execute(() -> { - filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor)); - filledAreas.add(this.floodFill(x, y + 1, lockedTiles, new ArrayList<>(), teamColor)); - filledAreas.add(this.floodFill(x - 1, y, lockedTiles, new ArrayList<>(), teamColor)); - filledAreas.add(this.floodFill(x + 1, y, lockedTiles, new ArrayList<>(), teamColor)); - - Optional> largestAreaOfAll = filledAreas.stream().filter(Objects::nonNull).max(Comparator.comparing(List::size)); - - if (largestAreaOfAll.isPresent()) { - for (RoomTile tile : largestAreaOfAll.get()) { - Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.x && i.getY() == tile.y && i instanceof InteractionBattleBanzaiTile).findAny(); - - tileItem.ifPresent(habboItem -> { - this.tileLocked(teamColor, habboItem, habbo, true); - - habboItem.setExtradata((2 + (teamColor.type * 3)) + ""); - this.room.updateItem(habboItem); - }); + synchronized (this.lockedTiles) { + if (item instanceof InteractionBattleBanzaiTile) { + if (!this.lockedTiles.containsKey(teamColor)) { + this.lockedTiles.put(teamColor, new THashSet<>()); } - this.refreshCounters(teamColor); - if (habbo != null) { - habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE * largestAreaOfAll.get().size()); - } + this.lockedTiles.get(teamColor).add(item); } - }); + + if (habbo != null) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked")); + } + + if (doNotCheckFill) return; + + final int x = item.getX(); + final int y = item.getY(); + + final List> filledAreas = new ArrayList<>(); + final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor)); + + executor.execute(() -> { + filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor)); + filledAreas.add(this.floodFill(x, y + 1, lockedTiles, new ArrayList<>(), teamColor)); + filledAreas.add(this.floodFill(x - 1, y, lockedTiles, new ArrayList<>(), teamColor)); + filledAreas.add(this.floodFill(x + 1, y, lockedTiles, new ArrayList<>(), teamColor)); + + Optional> largestAreaOfAll = filledAreas.stream().filter(Objects::nonNull).max(Comparator.comparing(List::size)); + + if (largestAreaOfAll.isPresent()) { + for (RoomTile tile : largestAreaOfAll.get()) { + Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.x && i.getY() == tile.y && i instanceof InteractionBattleBanzaiTile).findAny(); + + tileItem.ifPresent(habboItem -> { + this.tileLocked(teamColor, habboItem, habbo, true); + + habboItem.setExtradata((2 + (teamColor.type * 3)) + ""); + this.room.updateItem(habboItem); + }); + } + + this.refreshCounters(teamColor); + if (habbo != null) { + habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE * largestAreaOfAll.get().size()); + } + } + }); + } } private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index 8fb95dd4..6c8be89c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -110,15 +110,23 @@ public class InteractionWiredHighscore extends HabboItem { serverMessage.appendInt(this.clearType.type); if (this.data != null) { - serverMessage.appendInt(this.data.size()); + int size = this.data.size(); + if(size > 50) { + size = 50; + } + serverMessage.appendInt(size); + int count = 0; for (WiredHighscoreRow row : this.data) { - serverMessage.appendInt(row.getValue()); + if(count < 50) { + serverMessage.appendInt(row.getValue()); - serverMessage.appendInt(row.getUsers().size()); - for (String username : row.getUsers()) { - serverMessage.appendString(username); + serverMessage.appendInt(row.getUsers().size()); + for (String username : row.getUsers()) { + serverMessage.appendString(username); + } } + count++; } } else { serverMessage.appendInt(0); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index 5a326356..6632c2e4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -52,15 +52,19 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { if (game == null) return false; - TObjectIntIterator> iterator = this.data.iterator(); + int gameStartTime = game.getStartTime(); - for (int i = this.data.size(); i-- > 0; ) { + TObjectIntMap> dataClone = new TObjectIntHashMap<>(this.data); + + TObjectIntIterator> iterator = dataClone.iterator(); + + for (int i = dataClone.size(); i-- > 0; ) { iterator.advance(); Map.Entry map = iterator.key(); if (map.getValue() == habbo.getHabboInfo().getId()) { - if (map.getKey() == game.getStartTime()) { + if (map.getKey() == gameStartTime) { if (iterator.value() < this.count) { iterator.setValue(iterator.value() + 1); @@ -74,7 +78,13 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { } } - this.data.put(new AbstractMap.SimpleEntry<>(game.getStartTime(), habbo.getHabboInfo().getId()), 1); + try { + this.data.put(new AbstractMap.SimpleEntry<>(gameStartTime, habbo.getHabboInfo().getId()), 1); + } + catch(IllegalArgumentException e) { + + } + if (habbo.getHabboInfo().getGamePlayer() != null) { habbo.getHabboInfo().getGamePlayer().addScore(this.score, true); From 8f24dd48d0901c24049f2736d55c0c7e6cdc1b98 Mon Sep 17 00:00:00 2001 From: Kitt Mustang Date: Sun, 5 Sep 2021 02:53:10 +0000 Subject: [PATCH 14/94] Fix ticks in crackable furni interaction. --- .../habbohotel/items/interactions/InteractionCrackable.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java index 70869154..f9aed59a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java @@ -100,6 +100,11 @@ public class InteractionCrackable extends HabboItem { if (rewardData.requiredEffect > 0 && habbo.getRoomUnit().getEffectId() != rewardData.requiredEffect) return; + if(this.ticks < 1) + { + // If there are no ticks (for example because the room has been reloaded), check the current extradata of the item and update the ticks. + this.ticks = Integer.parseInt(this.getExtradata()); + } this.ticks++; this.setExtradata("" + (this.ticks)); this.needsUpdate(true); From 3ffee0aa4c1dc33fda6120df8d2f7717968de1c4 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sun, 5 Sep 2021 13:43:19 +0200 Subject: [PATCH 15/94] Ability to change guild settings while not in a room --- .../incoming/guilds/GuildChangeSettingsEvent.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java index 2cb2d807..d21df54b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildChangeSettingsEvent.java @@ -17,11 +17,6 @@ public class GuildChangeSettingsEvent extends MessageHandler { if (guild != null) { if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); - - if (room == null) - return; - GuildChangedSettingsEvent settingsEvent = new GuildChangedSettingsEvent(guild, this.packet.readInt(), this.packet.readInt() == 0); Emulator.getPluginManager().fireEvent(settingsEvent); @@ -31,7 +26,10 @@ public class GuildChangeSettingsEvent extends MessageHandler { guild.setState(GuildState.valueOf(settingsEvent.state)); guild.setRights(settingsEvent.rights); - room.refreshGuild(guild); + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); + if(room != null) { + room.refreshGuild(guild); + } guild.needsUpdate = true; From d327f8cbe683a7cf7fbb2b1d7b4de33f729867ac Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Tue, 7 Sep 2021 22:47:00 +0200 Subject: [PATCH 16/94] Accept friend request of offline user --- .../friends/AcceptFriendRequestEvent.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java index d5197131..d3f461bf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java @@ -3,11 +3,22 @@ package com.eu.habbo.messages.incoming.friends; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.FriendRequestErrorComposer; -import com.eu.habbo.plugin.PluginManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static com.eu.habbo.habbohotel.users.HabboManager.getOfflineHabboInfo; public class AcceptFriendRequestEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(AcceptFriendRequestEvent.class); + @Override public void handle() throws Exception { int count = this.packet.readInt(); @@ -26,6 +37,28 @@ public class AcceptFriendRequestEvent extends MessageHandler { Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); + if(target == null) { + HabboInfo habboInfo = getOfflineHabboInfo(userId); + + if(habboInfo == null) { + this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_FOUND)); + this.client.getHabbo().getMessenger().deleteFriendRequests(userId, this.client.getHabbo().getHabboInfo().getId()); + continue; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.*, users_settings.block_friendrequests FROM users INNER JOIN users_settings ON users.id = users_settings.user_id WHERE username = ? LIMIT 1")) { + statement.setString(1, habboInfo.getUsername()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + target = new Habbo(set); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + return; + } + } + if(target == null) { this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.TARGET_NOT_FOUND)); this.client.getHabbo().getMessenger().deleteFriendRequests(userId, this.client.getHabbo().getHabboInfo().getId()); From 7b1e94cf17388cda7cc6fce7461473351186e922 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Thu, 7 Oct 2021 19:08:03 +0200 Subject: [PATCH 17/94] Correct amount of max rooms --- .../messages/incoming/navigator/RequestCanCreateRoomEvent.java | 2 +- .../messages/incoming/navigator/RequestCreateRoomEvent.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java index d1ed2bf0..b2b93714 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCanCreateRoomEvent.java @@ -9,7 +9,7 @@ public class RequestCanCreateRoomEvent extends MessageHandler { @Override public void handle() throws Exception { int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size(); - int max = this.client.getHabbo().getHabboStats().maxRooms; + int max = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_HC : RoomManager.MAXIMUM_ROOMS_USER; this.client.sendResponse(new CanCreateRoomComposer(count, max)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java index d0f8f83a..c5e921f3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java @@ -48,7 +48,7 @@ public class RequestCreateRoomEvent extends MessageHandler { return; int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size(); - int max = this.client.getHabbo().getHabboStats().maxRooms; + int max = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_HC : RoomManager.MAXIMUM_ROOMS_USER; if (count >= max) { this.client.sendResponse(new CanCreateRoomComposer(count, max)); From 8da35220e3581bbcbb71c1fe86e58485a39b27a5 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Fri, 8 Oct 2021 22:50:24 +0200 Subject: [PATCH 18/94] Fix room lay rotation with beds from FurniBuilder --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 869562ef..5e87ce8e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1672,7 +1672,7 @@ public class Room implements Comparable, ISerialize, Runnable { } else { if (!unit.hasStatus(RoomUnitStatus.LAY)) { unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) * 1.0D + ""); - unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); + unit.setRotation(RoomUserRotation.values()[topItem.getRotation() % 4]); if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { unit.setLocation(this.layout.getTile(unit.getX(), topItem.getY())); From 3ab32b6850ac8961689bbd336cafcda96cd0379d Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sat, 9 Oct 2021 00:22:16 +0200 Subject: [PATCH 19/94] Debug mode for the non existent SSO message --- .../habbo/messages/incoming/handshake/SecureLoginEvent.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 82ab0bf1..fbde40cb 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 @@ -73,7 +73,9 @@ public class SecureLoginEvent extends MessageHandler { if (sso.isEmpty()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - LOGGER.warn("Client is trying to connect without SSO ticket! Closed connection..."); + if (Emulator.getConfig().getBoolean("debug.mode")) { + LOGGER.warn("Client is trying to connect without SSO ticket! Closed connection..."); + } return; } From 86cf51ab05fc9fd6108c1a66e231f6f3546a9932 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sat, 20 Nov 2021 02:55:26 +0100 Subject: [PATCH 20/94] New event to be able to edit floor items while loading room (to hide furniture for example) --- .../habbo/habbohotel/rooms/RoomManager.java | 13 +++++++- .../events/rooms/RoomFloorItemsLoadEvent.java | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java 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 05ddc66a..eb9af764 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -42,11 +42,13 @@ import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageCompo import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; +import com.eu.habbo.plugin.events.rooms.RoomFloorItemsLoadEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent; import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent; +import com.eu.habbo.plugin.events.users.UsernameTalkEvent; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TIntProcedure; @@ -788,7 +790,16 @@ public class RoomManager { { final THashSet floorItems = new THashSet<>(); - room.getFloorItems().forEach(new TObjectProcedure() { + THashSet allFloorItems = new THashSet<>(room.getFloorItems()); + + if (Emulator.getPluginManager().isRegistered(RoomFloorItemsLoadEvent.class, true)) { + RoomFloorItemsLoadEvent roomFloorItemsLoadEvent = Emulator.getPluginManager().fireEvent(new RoomFloorItemsLoadEvent(habbo, allFloorItems)); + if (roomFloorItemsLoadEvent.hasChangedFloorItems()) { + allFloorItems = roomFloorItemsLoadEvent.getFloorItems(); + } + } + + allFloorItems.forEach(new TObjectProcedure() { @Override public boolean execute(HabboItem object) { if (room.isHideWired() && object instanceof InteractionWired) diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java new file mode 100644 index 00000000..01bea305 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/rooms/RoomFloorItemsLoadEvent.java @@ -0,0 +1,30 @@ +package com.eu.habbo.plugin.events.rooms; + +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.plugin.events.users.UserEvent; +import gnu.trove.set.hash.THashSet; + +public class RoomFloorItemsLoadEvent extends UserEvent { + private THashSet floorItems; + private boolean changedFloorItems; + + public RoomFloorItemsLoadEvent(Habbo habbo, THashSet floorItems) { + super(habbo); + this.floorItems = floorItems; + this.changedFloorItems = false; + } + + public void setFloorItems(THashSet floorItems) { + this.changedFloorItems = true; + this.floorItems = floorItems; + } + + public boolean hasChangedFloorItems() { + return this.changedFloorItems; + } + + public THashSet getFloorItems() { + return this.floorItems; + } +} From 92636bbdc5661e6cfe3e24f2ee7235a55613cb60 Mon Sep 17 00:00:00 2001 From: duckietm Date: Thu, 9 Dec 2021 07:39:16 +0000 Subject: [PATCH 21/94] Update database to enable or disable TTY in console --- sqlupdates/3_0_BETA_1 to 3_0_0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sqlupdates/3_0_BETA_1 to 3_0_0.sql b/sqlupdates/3_0_BETA_1 to 3_0_0.sql index 31e6474c..b28d10ce 100644 --- a/sqlupdates/3_0_BETA_1 to 3_0_0.sql +++ b/sqlupdates/3_0_BETA_1 to 3_0_0.sql @@ -7,3 +7,6 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.item_count -- Enable bubble alerts INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('bubblealerts.enabled', '1'); + +-- Enable or Disable TTY in console (Default is enabled) +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '0'); From f167c6b6cd25a9e9621c5a6e6792eb552ba437e8 Mon Sep 17 00:00:00 2001 From: duckietm Date: Thu, 9 Dec 2021 07:41:10 +0000 Subject: [PATCH 22/94] Adding TTY setting in the emulator --- src/main/java/com/eu/habbo/Emulator.java | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 97fe313a..affec180 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -175,26 +175,30 @@ public final class Emulator { Runtime.getRuntime().availableProcessors() * 2); } - Emulator.getThreading().run(() -> { }, 1500); - BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + // Check if console mode is true or false, default is true + if (Emulator.getConfig().getBoolean("console.mode", true)) { - while (!isShuttingDown && isReady) { - try { - String line = reader.readLine(); + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); - if (line != null) { - ConsoleCommand.handle(line); - } - System.out.println("Waiting for command: "); - } catch (Exception e) { - if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { - LOGGER.error("Error while reading command", e); + while (!isShuttingDown && isReady) { + try { + String line = reader.readLine(); + + if (line != null) { + ConsoleCommand.handle(line); + } + System.out.println("Waiting for command: "); + } catch (Exception e) { + if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { + LOGGER.error("Error while reading command", e); + } } } } + } catch (Exception e) { e.printStackTrace(); } From c78813a405af6e4eede6fc6052d201249bff999c Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Sun, 19 Dec 2021 15:05:48 +0000 Subject: [PATCH 23/94] Fixed Possible NPE's with System.getProperty --- src/main/java/com/eu/habbo/Emulator.java | 4 ++-- .../habbohotel/wired/highscores/WiredHighscoreManager.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 97fe313a..f10c5404 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -32,8 +32,8 @@ import java.util.regex.Pattern; public final class Emulator { private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class); - private static final String OS_NAME = System.getProperty("os.name"); - private static final String CLASS_PATH = System.getProperty("java.class.path"); + private static final String OS_NAME = (System.getProperty("os.name") != null ? System.getProperty("os.name") : "Unknown"); + private static final String CLASS_PATH = (System.getProperty("java.class.path") != null ? System.getProperty("java.class.path") : "Unknown"); public final static int MAJOR = 3; public final static int MINOR = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index 31431699..e7cf9cef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -22,8 +22,11 @@ public class WiredHighscoreManager { private static final Logger LOGGER = LoggerFactory.getLogger(WiredHighscoreManager.class); private final HashMap> data = new HashMap<>(); + + private final static String locale = (System.getProperty("user.language") != null ? System.getProperty("user.language") : "en"); + private final static String country = (System.getProperty("user.country") != null ? System.getProperty("user.country") : "US"); - private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(System.getProperty("user.language"), System.getProperty("user.country"))).getFirstDayOfWeek(); + private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(locale, country)).getFirstDayOfWeek(); private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1); private final static ZoneId zoneId = ZoneId.systemDefault(); From a5d11b98e2e9ce81d0eea1fa93034744c383c3c1 Mon Sep 17 00:00:00 2001 From: duckietm Date: Mon, 20 Dec 2021 20:13:31 +0000 Subject: [PATCH 24/94] Move the update --- sqlupdates/3_0_BETA_1 to 3_0_0.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/sqlupdates/3_0_BETA_1 to 3_0_0.sql b/sqlupdates/3_0_BETA_1 to 3_0_0.sql index b28d10ce..31e6474c 100644 --- a/sqlupdates/3_0_BETA_1 to 3_0_0.sql +++ b/sqlupdates/3_0_BETA_1 to 3_0_0.sql @@ -7,6 +7,3 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('wired.variable.item_count -- Enable bubble alerts INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('bubblealerts.enabled', '1'); - --- Enable or Disable TTY in console (Default is enabled) -INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '0'); From 7d8c4747a71beae795d5a58223aab1e4557732b6 Mon Sep 17 00:00:00 2001 From: duckietm Date: Mon, 20 Dec 2021 20:13:55 +0000 Subject: [PATCH 25/94] Update 3_0_0 to 3_0_1.sql --- sqlupdates/3_0_0 to 3_0_1.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 674b2097..b41da52a 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -1,4 +1,7 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.place.under', '0'); INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.custom.enabled', '0'); -INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk.forgot_username', 'Specify the username of the Habbo you want to follow!'); \ No newline at end of file +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk.forgot_username', 'Specify the username of the Habbo you want to follow!'); + +-- Enable or Disable TTY in console (Default is enabled) +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '0'); From 8b7859e5590206e34088ac71c49f3378626f3695 Mon Sep 17 00:00:00 2001 From: duckietm Date: Mon, 20 Dec 2021 20:24:18 +0000 Subject: [PATCH 26/94] Console output enabled by default --- sqlupdates/3_0_0 to 3_0_1.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index b41da52a..4a1d34e7 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -4,4 +4,4 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.custom.enabled', INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk.forgot_username', 'Specify the username of the Habbo you want to follow!'); -- Enable or Disable TTY in console (Default is enabled) -INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '0'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1'); From da789fcc1e56fe5fac1762c04dfe4818d1366b0e Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Sun, 2 Jan 2022 04:16:22 +0000 Subject: [PATCH 27/94] Added Check for Kick Permission. --- .../com/eu/habbo/habbohotel/commands/SoftKickCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java index c89ab075..6efc14c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java @@ -30,7 +30,9 @@ public class SoftKickCommand extends Command { final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); if (room != null) { - room.kickHabbo(habbo, false); + if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { + room.kickHabbo(habbo, false); + } } } return true; From f99de2009cc4caf66b74a495154e8b521288064f Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Wed, 5 Jan 2022 19:42:04 +0000 Subject: [PATCH 28/94] Yikes Sorry. --- .../com/eu/habbo/habbohotel/commands/SoftKickCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java index c89ab075..b841b945 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; @@ -30,7 +31,9 @@ public class SoftKickCommand extends Command { final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); if (room != null) { - room.kickHabbo(habbo, false); + if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) { + room.kickHabbo(habbo, false); + } } } return true; From 0abfc64acb0b588ddaab6f0672574dd368865185 Mon Sep 17 00:00:00 2001 From: xjoao Date: Thu, 6 Jan 2022 11:08:01 +0000 Subject: [PATCH 29/94] Update ModToolIssue.java removed semicolon --- src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java index 14a0b737..f9b008db 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -52,7 +52,7 @@ public class ModToolIssue implements ISerialize { int photoItemId = set.getInt("photo_item_id"); if (photoItemId != -1) { - this.photoItem = Emulator.getGameEnvironment().getItemManager().loadHabboItem(photoItemId);; + this.photoItem = Emulator.getGameEnvironment().getItemManager().loadHabboItem(photoItemId); } if (this.modId <= 0) { From f126115c3db8cef1b62cd02380c3abb2488d50dd Mon Sep 17 00:00:00 2001 From: brenoepic Date: Tue, 18 Jan 2022 20:36:21 +0000 Subject: [PATCH 30/94] Fix ColorWheel interaction --- .../habbohotel/items/interactions/InteractionColorWheel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java index 55c896fa..8105464c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java @@ -49,7 +49,7 @@ public class InteractionColorWheel extends HabboItem { if (!room.hasRights(client.getHabbo())) return; - if (this.rollTaks == null) { + if (this.rollTaks == null && !this.getExtradata().equalsIgnoreCase("-1")) { this.setExtradata("-1"); room.sendComposer(new WallItemUpdateComposer(this).compose()); Emulator.getThreading().run(this); From afcffa96a339a972880312e369295fb28264343e Mon Sep 17 00:00:00 2001 From: brenoepic Date: Tue, 18 Jan 2022 21:54:36 +0000 Subject: [PATCH 31/94] Fix Buy furniture with a badge attatched already own --- .../java/com/eu/habbo/habbohotel/catalog/CatalogManager.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 6e7908c2..5058b78c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -1079,12 +1079,9 @@ public class CatalogManager { } } - if (badgeFound) { + if (badgeFound && item.getBaseItems().size() == 1) { habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.ALREADY_HAVE_BADGE)); - - if (item.getBaseItems().size() == 1) { return; - } } UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges); From ba6a849972c51805e8b0739a57c93d8341900e1b Mon Sep 17 00:00:00 2001 From: xjoao Date: Thu, 20 Jan 2022 12:06:04 +0000 Subject: [PATCH 32/94] Update Navigator Manager --- .../com/eu/habbo/habbohotel/navigation/NavigatorManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java index e4fea5b7..b5deefd5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -78,7 +78,7 @@ public class NavigatorManager { Class clazz = Room.class; if (set.getString("field").contains(".")) { - for (String s : (set.getString("field")).split(".")) { + for (String s : (set.getString("field")).split("\\.")) { try { field = clazz.getDeclaredMethod(s); clazz = field.getReturnType(); From d2fc1d6827d56acf17f1953d16e6ae4b898eb64b Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sat, 22 Jan 2022 02:51:57 +0100 Subject: [PATCH 33/94] Offer ID fix for catalog page highlights --- .../messages/incoming/catalog/RequestCatalogPageEvent.java | 4 ++-- .../messages/outgoing/catalog/CatalogPageComposer.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java index 2e0f73c5..0198c01e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestCatalogPageEvent.java @@ -11,14 +11,14 @@ public class RequestCatalogPageEvent extends MessageHandler { @Override public void handle() throws Exception { int catalogPageId = this.packet.readInt(); - int unknown = this.packet.readInt(); + int offerId = this.packet.readInt(); String mode = this.packet.readString(); CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().catalogPages.get(catalogPageId); if (catalogPageId > 0 && page != null) { if (page.getRank() <= this.client.getHabbo().getHabboInfo().getRank().getId() && page.isEnabled()) { - this.client.sendResponse(new CatalogPageComposer(page, this.client.getHabbo(), mode)); + this.client.sendResponse(new CatalogPageComposer(page, this.client.getHabbo(), offerId, mode)); } else { if (!page.isVisible()) { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.catalog.page").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%pagename%", page.getCaption())); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java index 9c0c682f..d1ba4480 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java @@ -20,11 +20,13 @@ import java.util.Map; public class CatalogPageComposer extends MessageComposer { private final CatalogPage page; private final Habbo habbo; + private final int offerId; private final String mode; - public CatalogPageComposer(CatalogPage page, Habbo habbo, String mode) { + public CatalogPageComposer(CatalogPage page, Habbo habbo, int offerId, String mode) { this.page = page; this.habbo = habbo; + this.offerId = offerId; this.mode = mode; } @@ -49,7 +51,7 @@ public class CatalogPageComposer extends MessageComposer { item.serialize(this.response); } } - this.response.appendInt(0); + this.response.appendInt(offerId); this.response.appendBoolean(false); //acceptSeasonCurrencyAsCredits if (this.page instanceof FrontPageFeaturedLayout || this.page instanceof FrontpageLayout) { From 4b207a39935c5ca1d6f9cf5e0f76866c56babddf Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sat, 22 Jan 2022 02:55:14 +0100 Subject: [PATCH 34/94] added this. --- .../eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java index d1ba4480..0f4d8bd5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPageComposer.java @@ -51,7 +51,7 @@ public class CatalogPageComposer extends MessageComposer { item.serialize(this.response); } } - this.response.appendInt(offerId); + this.response.appendInt(this.offerId); this.response.appendBoolean(false); //acceptSeasonCurrencyAsCredits if (this.page instanceof FrontPageFeaturedLayout || this.page instanceof FrontpageLayout) { From 7b882fd8e753a636a5622847c73191e96b223ddf Mon Sep 17 00:00:00 2001 From: Snaiker Date: Thu, 27 Jan 2022 12:08:51 +0000 Subject: [PATCH 35/94] Fix crackable wall item issue --- .../eu/habbo/threading/runnables/CrackableExplode.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java index d39b2f57..f5da2ca8 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -1,6 +1,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionCrackable; import com.eu.habbo.habbohotel.rooms.Room; @@ -34,7 +35,7 @@ public class CrackableExplode implements Runnable { if (this.habboItem.getRoomId() == 0) { return; } -//MAKING DINNER BRB + if (!this.habboItem.resetable()) { this.room.removeHabboItem(this.habboItem); this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose()); @@ -43,13 +44,15 @@ public class CrackableExplode implements Runnable { } else { this.habboItem.reset(this.room); } + Item rewardItem = Emulator.getGameEnvironment().getItemManager().getCrackableReward(this.habboItem.getBaseItem().getId()); if (rewardItem != null) { HabboItem newItem = Emulator.getGameEnvironment().getItemManager().createItem(this.habboItem.allowAnyone() ? this.habbo.getHabboInfo().getId() : this.habboItem.getUserId(), rewardItem, 0, 0, ""); if (newItem != null) { - if (this.toInventory) { + //Add to inventory in case if isn't possible place the item or in case is wall item + if (this.toInventory || newItem.getBaseItem().getType() == FurnitureType.WALL) { this.habbo.getInventory().getItemsComponent().addItem(newItem); this.habbo.getClient().sendResponse(new AddHabboItemComposer(newItem)); this.habbo.getClient().sendResponse(new InventoryRefreshComposer()); @@ -66,7 +69,6 @@ public class CrackableExplode implements Runnable { } } - this.room.updateTile(this.room.getLayout().getTile(this.x, this.y)); } } From f022c31f3d336dd7aa0aab1d3d9530ea75c81102 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Mon, 21 Feb 2022 17:49:03 -0300 Subject: [PATCH 36/94] Update ModToolManager.java --- .../java/com/eu/habbo/habbohotel/modtool/ModToolManager.java | 2 -- 1 file changed, 2 deletions(-) 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 2a65ba4a..3b8e5b3b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -184,8 +184,6 @@ public class ModToolManager { public void quickTicket(Habbo reported, String reason, String message) { ModToolIssue issue = new ModToolIssue(0, reason, reported.getHabboInfo().getId(), reported.getHabboInfo().getUsername(), 0, message, ModToolTicketType.AUTOMATIC); - if (Emulator.getPluginManager().fireEvent(new SupportTicketEvent(null, issue)).isCancelled()) - return; Emulator.getGameEnvironment().getModToolManager().addTicket(issue); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); From fd8401d4fd57049b71e5981a469a9c5879d71315 Mon Sep 17 00:00:00 2001 From: dap <90627349+notdap@users.noreply.github.com> Date: Wed, 2 Mar 2022 15:45:31 +0100 Subject: [PATCH 37/94] Fix issue #980 --- .../messages/incoming/rooms/items/PostItSaveDataEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java index 2922fc94..a2bb5524 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java @@ -39,12 +39,12 @@ public class PostItSaveDataEvent extends MessageHandler { if (!(item instanceof InteractionPostIt)) return; - if (!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.hasRights(this.client.getHabbo()) && item.getUserId() != this.client.getHabbo().getHabboInfo().getId()) { + if (!color.equalsIgnoreCase(PostItColor.YELLOW.hexColor) && !room.hasRights(this.client.getHabbo())) { if (!text.startsWith(item.getExtradata().replace(item.getExtradata().split(" ")[0], ""))) { return; } } else { - if (!room.hasRights(this.client.getHabbo()) && item.getUserId() != this.client.getHabbo().getHabboInfo().getId()) + if (!room.hasRights(this.client.getHabbo())) return; } From c865bb23829bceb24dae27265e3dd3a1b209b728 Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 2 Mar 2022 21:44:53 +0000 Subject: [PATCH 38/94] Addresses #889: update mysql connector --- pom.xml | 2 +- src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 50967e7b..4cfb2d74 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ mysql mysql-connector-java - 5.1.49 + 8.0.22 runtime 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..144dd93f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -257,7 +257,7 @@ public class HabboStats implements Runnable { try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_settings WHERE user_id = ? LIMIT 1")) { statement.setInt(1, habboInfo.getId()); try (ResultSet set = statement.executeQuery()) { - set.first(); + set.next(); if (set.getRow() != 0) { stats = new HabboStats(set, habboInfo); } else { From 662befaeb33803f30c05c90b6d5b616e7f543739 Mon Sep 17 00:00:00 2001 From: brenoepic Date: Wed, 2 Mar 2022 22:13:56 +0000 Subject: [PATCH 39/94] Fix YoutubeTV --- sqlupdates/3_0_0 to 3_0_1.sql | 3 + .../habbohotel/items/YoutubeManager.java | 153 ++++++++++++------ .../youtube/YoutubeRequestStateChange.java | 6 +- 3 files changed, 110 insertions(+), 52 deletions(-) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 4a1d34e7..9cbec636 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -5,3 +5,6 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk. -- Enable or Disable TTY in console (Default is enabled) INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1'); + +-- Youtube Api v3 key to YoutubeManager +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('youtube.apikey', ''); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java index 3be71726..a383541a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -11,10 +11,12 @@ import org.slf4j.LoggerFactory; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.sql.*; +import java.time.Duration; import java.util.ArrayList; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -23,7 +25,7 @@ import java.util.concurrent.TimeUnit; public class YoutubeManager { private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeManager.class); - public class YoutubeVideo { + public static class YoutubeVideo { private final String id; private final int duration; @@ -41,7 +43,7 @@ public class YoutubeManager { } } - public class YoutubePlaylist { + public static class YoutubePlaylist { private final String id; private final String name; private final String description; @@ -71,8 +73,9 @@ public class YoutubeManager { } } - private THashMap> playlists = new THashMap<>(); - private THashMap playlistCache = new THashMap<>(); + private final THashMap> playlists = new THashMap<>(); + private final THashMap playlistCache = new THashMap<>(); + private final String apiKey = Emulator.getConfig().getValue("youtube.apikey"); public void load() { this.playlists.clear(); @@ -94,11 +97,15 @@ public class YoutubeManager { youtubeDataLoaderPool.submit(() -> { ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); - YoutubePlaylist playlist = this.getPlaylistDataById(playlistId); - if (playlist != null) { - playlists.add(playlist); - } else { - LOGGER.error("Failed to load YouTube playlist: " + playlistId); + YoutubePlaylist playlist; + + try { + playlist = this.getPlaylistDataById(playlistId); + if (playlist != null) { + playlists.add(playlist); + } + } catch (IOException e) { + LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); } this.playlists.put(itemId, playlists); @@ -120,56 +127,102 @@ public class YoutubeManager { }); } - public YoutubePlaylist getPlaylistDataById(String playlistId) { + public YoutubePlaylist getPlaylistDataById(String playlistId) throws IOException { if (this.playlistCache.containsKey(playlistId)) return this.playlistCache.get(playlistId); + if(apiKey.isEmpty()) return null; - try { - URL myUrl = new URL("https://www.youtube.com/playlist?list=" + playlistId); + YoutubePlaylist playlist; + URL playlistInfo = new URL("https://youtube.googleapis.com/youtube/v3/playlists?part=snippet&id=" + playlistId + "&maxResults=1&key=" + apiKey); + HttpsURLConnection playlistCon = (HttpsURLConnection) playlistInfo.openConnection(); + if (playlistCon.getResponseCode() != 200) { + InputStream errorInputStream = playlistCon.getErrorStream(); + InputStreamReader playlistISR = new InputStreamReader(errorInputStream); + BufferedReader playlistBR = new BufferedReader(playlistISR); + JsonObject errorObj = JsonParser.parseReader(playlistBR).getAsJsonObject(); + String message = errorObj.get("error").getAsJsonObject().get("message").getAsString(); + LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, message); + return null; + } + InputStream playlistInputStream = playlistCon.getInputStream(); + InputStreamReader playlistISR = new InputStreamReader(playlistInputStream); + BufferedReader playlistBR = new BufferedReader(playlistISR); - HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection(); - conn.setRequestProperty("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"); - conn.setRequestProperty("accept-language", "en-GB,en-US;q=0.9,en;q=0.8"); - conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3731.0 Safari/537.36"); + JsonObject playlistData = JsonParser.parseReader(playlistBR).getAsJsonObject(); - InputStream is = conn.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - YoutubePlaylist playlist; - try (BufferedReader br = new BufferedReader(isr)) { - playlist = null; - String inputLine; - while ((inputLine = br.readLine()) != null) { - if (inputLine.contains("window[\"ytInitialData\"]")) { - JsonObject obj = new JsonParser().parse(inputLine.substring(inputLine.indexOf("{")).replace(";", "")).getAsJsonObject(); - - JsonObject meta = obj.get("microformat").getAsJsonObject().get("microformatDataRenderer").getAsJsonObject(); - String name = meta.get("title").getAsString(); - String description = meta.get("description").getAsString(); - - ArrayList videos = new ArrayList<>(); - - JsonArray rawVideos = obj.get("contents").getAsJsonObject().get("twoColumnBrowseResultsRenderer").getAsJsonObject().get("tabs").getAsJsonArray().get(0).getAsJsonObject().get("tabRenderer").getAsJsonObject().get("content").getAsJsonObject().get("sectionListRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("itemSectionRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("playlistVideoListRenderer").getAsJsonObject().get("contents").getAsJsonArray(); - - for (JsonElement rawVideo : rawVideos) { - JsonObject videoData = rawVideo.getAsJsonObject().get("playlistVideoRenderer").getAsJsonObject(); - if (!videoData.has("lengthSeconds")) continue; // removed videos - videos.add(new YoutubeVideo(videoData.get("videoId").getAsString(), Integer.valueOf(videoData.get("lengthSeconds").getAsString()))); - } - - playlist = new YoutubePlaylist(playlistId, name, description, videos); - - break; - } - } + JsonArray playlists = playlistData.get("items").getAsJsonArray(); + if (playlists.size() == 0) { + LOGGER.error("Playlist {} not found!", playlistId); + return null; + } + JsonObject playlistItem = playlists.get(0).getAsJsonObject().get("snippet").getAsJsonObject(); + + String name = playlistItem.get("title").getAsString(); + String description = playlistItem.get("description").getAsString(); + + ArrayList < YoutubeVideo > videos = new ArrayList < > (); + String nextPageToken = ""; + do { + ArrayList < String > videoIds = new ArrayList < > (); + URL playlistItems; + + if (nextPageToken.isEmpty()) { + playlistItems = new URL("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&maxResults=50&key=" + apiKey); + } else { + playlistItems = new URL("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&pageToken=" + nextPageToken + "&maxResults=50&key=" + apiKey); } - this.playlistCache.put(playlistId, playlist); + HttpsURLConnection con = (HttpsURLConnection) playlistItems.openConnection(); - return playlist; - } catch (java.io.IOException e) { - e.printStackTrace(); + InputStream is = con.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + JsonObject object = JsonParser.parseReader(br).getAsJsonObject(); + + JsonArray rawV = object.get("items").getAsJsonArray(); + for (JsonElement rawVideo: rawV) { + JsonObject videoData = rawVideo.getAsJsonObject().get("snippet").getAsJsonObject(); + JsonObject videoStatus = rawVideo.getAsJsonObject().get("status").getAsJsonObject(); + if (!videoStatus.get("privacyStatus").getAsString().equals("public")) + continue; // removed videos + videoIds.add(videoData.get("resourceId").getAsJsonObject().get("videoId").getAsString()); + } + + if (!videoIds.isEmpty()) { + URL VideoItems; + + String commaSeparatedVideos = String.join(",", videoIds); + + VideoItems = new URL("https://youtube.googleapis.com/youtube/v3/videos?part=contentDetails&id=" + commaSeparatedVideos + "&maxResults=50&key=" + apiKey); + HttpsURLConnection con1 = (HttpsURLConnection) VideoItems.openConnection(); + InputStream is1 = con1.getInputStream(); + InputStreamReader isr1 = new InputStreamReader(is1); + BufferedReader br1 = new BufferedReader(isr1); + JsonObject object1 = JsonParser.parseReader(br1).getAsJsonObject(); + JsonArray Vds = object1.get("items").getAsJsonArray(); + for (JsonElement rawVideo: Vds) { + JsonObject contentDetails = rawVideo.getAsJsonObject().get("contentDetails").getAsJsonObject(); + int duration = (int) Duration.parse(contentDetails.get("duration").getAsString()).getSeconds(); + if (duration < 1) continue; + videos.add(new YoutubeVideo(rawVideo.getAsJsonObject().get("id").getAsString(), duration)); + } + } + if (object.has("nextPageToken")) { + nextPageToken = object.get("nextPageToken").getAsString(); + } else { + nextPageToken = null; + } + } while (nextPageToken != null); + + if (videos.isEmpty()) { + LOGGER.warn("Playlist {} has no videos!", playlistId); + return null; } + playlist = new YoutubePlaylist(playlistId, name, description, videos); + + this.playlistCache.put(playlistId, playlist); + + return playlist; - return null; } public ArrayList getPlaylistsForItemId(int itemId) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java index f212e698..b9010e5a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestStateChange.java @@ -64,10 +64,12 @@ public class YoutubeRequestStateChange extends MessageHandler { HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId); - if (item == null || !(item instanceof InteractionYoutubeTV)) return; + if (!(item instanceof InteractionYoutubeTV)) return; InteractionYoutubeTV tv = (InteractionYoutubeTV) item; + if(tv.currentPlaylist == null || tv.currentPlaylist.getVideos().isEmpty()) return; + switch (state) { case PAUSE: tv.playing = false; @@ -104,4 +106,4 @@ public class YoutubeRequestStateChange extends MessageHandler { room.updateItem(tv); } } -} \ No newline at end of file +} From 3b8caee5de97f5961622dab9fd21fb23bae7be08 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Wed, 2 Mar 2022 22:20:16 +0000 Subject: [PATCH 40/94] Cleanup redeem voucher --- .../habbohotel/catalog/CatalogManager.java | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 5058b78c..6eb01a77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -523,7 +523,6 @@ public class CatalogManager { return null; } - public Voucher getVoucher(String code) { synchronized (this.vouchers) { for (Voucher voucher : this.vouchers) { @@ -535,22 +534,20 @@ public class CatalogManager { return null; } - public void redeemVoucher(GameClient client, String voucherCode) { - Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode); + Habbo habbo = client.getHabbo(); + if (habbo == null) + return; + Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode); if (voucher == null) { client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE)); return; } - Habbo habbo = client.getHabbo(); - if (habbo == null) return; - if (voucher.isExhausted()) { - if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { - client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR)); - } + client.sendResponse(new RedeemVoucherErrorComposer(Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher) ? RedeemVoucherErrorComposer.INVALID_CODE : RedeemVoucherErrorComposer.TECHNICAL_ERROR)); + return; } if (voucher.hasUserExhausted(habbo.getHabboInfo().getId())) { @@ -560,12 +557,6 @@ public class CatalogManager { voucher.addHistoryEntry(habbo.getHabboInfo().getId()); - if (voucher.isExhausted()) { - if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { - client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR)); - } - } - if (voucher.points > 0) { client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType)); @@ -578,7 +569,6 @@ public class CatalogManager { if (voucher.catalogItemId > 0) { CatalogItem item = this.getCatalogItem(voucher.catalogItemId); - if (item != null) { this.purchaseItem(null, item, client.getHabbo(), 1, "", true); } @@ -587,7 +577,6 @@ public class CatalogManager { client.sendResponse(new RedeemVoucherOKComposer()); } - public boolean deleteVoucher(Voucher voucher) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM vouchers WHERE code = ?")) { statement.setString(1, voucher.code); From a7780542419296ff7f29dd9345e81eb04c1b8a56 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:24:48 -0300 Subject: [PATCH 41/94] calendar update --- .../eu/habbo/habbohotel/GameEnvironment.java | 6 + .../campaign/calendar/CalendarCampaign.java | 64 ++++++++ .../campaign/calendar/CalendarManager.java | 154 ++++++++++++++++++ .../calendar/CalendarRewardClaimed.java | 50 ++++++ .../calendar}/CalendarRewardObject.java | 45 ++++- .../habbohotel/catalog/CatalogManager.java | 43 +---- .../habbohotel/commands/CalendarCommand.java | 20 ++- .../habbohotel/commands/CommandHandler.java | 1 + .../commands/UpdateCalendarCommand.java | 21 +++ .../eu/habbo/habbohotel/users/HabboStats.java | 7 +- .../AdventCalendarForceOpenEvent.java | 4 +- .../calendar/AdventCalendarOpenDayEvent.java | 4 +- .../incoming/handshake/UsernameEvent.java | 18 +- .../calendar/AdventCalendarDataComposer.java | 22 ++- .../AdventCalendarProductComposer.java | 32 +++- .../users/calendar/UserClaimRewardEvent.java | 23 +++ 16 files changed, 445 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java rename src/main/java/com/eu/habbo/habbohotel/{catalog => campaign/calendar}/CalendarRewardObject.java (59%) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java create mode 100644 src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index a614cb05..7944ae8c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.*; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.BotManager; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.commands.CommandHandler; import com.eu.habbo.habbohotel.crafting.CraftingManager; @@ -54,6 +55,7 @@ public class GameEnvironment { private CraftingManager craftingManager; private PollManager pollManager; private SubscriptionManager subscriptionManager; + private CalendarManager calendarManager; public void load() throws Exception { LOGGER.info("GameEnvironment -> Loading..."); @@ -78,6 +80,7 @@ public class GameEnvironment { this.wordFilter = new WordFilter(); this.craftingManager = new CraftingManager(); this.pollManager = new PollManager(); + this.calendarManager = new CalendarManager(); this.roomManager.loadPublicRooms(); this.navigatorManager.loadNavigator(); @@ -114,6 +117,7 @@ public class GameEnvironment { this.itemManager.dispose(); this.hotelViewManager.dispose(); this.subscriptionManager.dispose(); + this.calendarManager.dispose(); LOGGER.info("GameEnvironment -> Disposed!"); } @@ -206,4 +210,6 @@ public class GameEnvironment { public SubscriptionManager getSubscriptionManager() { return this.subscriptionManager; } + + public CalendarManager getCalendarManager() { return this.calendarManager; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java new file mode 100644 index 00000000..b00cf7fc --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java @@ -0,0 +1,64 @@ +package com.eu.habbo.habbohotel.campaign.calendar; + +import gnu.trove.map.hash.THashMap; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Map; + +public class CalendarCampaign { + private int id; + private final String name; + private final String image; + private Map rewards = new THashMap<>(); + private final Timestamp start_timestamp; + private final int total_days; + private final boolean lock_expired; + + public CalendarCampaign(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.name = set.getString("name"); + this.image = set.getString("image"); + this.start_timestamp = set.getTimestamp("start_timestamp"); + this.total_days = set.getInt("total_days"); + this.lock_expired = set.getInt("lock_expired") == 1; + } + + public CalendarCampaign(int id, String name, String image, Timestamp start_timestamp, int total_days, boolean lock_expired) { + this.id = id; + this.name = name; + this.image = image; + this.start_timestamp = start_timestamp; + this.total_days = total_days; + this.lock_expired = lock_expired; + } + + public int getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public String getImage() { + return this.image; + } + + public Timestamp getStartTimestamp() { + return this.start_timestamp; + } + + public int getTotalDays() { return this.total_days; } + + public boolean getLockExpired() { return this.lock_expired; } + + public Map getRewards() { return rewards; } + + public void setId(int id) { this.id = id; } + + public void setRewards(Map rewards) { this.rewards = rewards; } + + public void addReward(CalendarRewardObject reward) { this.rewards.put(reward.getId(), reward); } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java new file mode 100644 index 00000000..4e2720e8 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java @@ -0,0 +1,154 @@ +package com.eu.habbo.habbohotel.campaign.calendar; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer; +import com.eu.habbo.plugin.events.users.calendar.UserClaimRewardEvent; +import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.*; +import java.util.*; +import java.util.Date; + +import static java.time.temporal.ChronoUnit.DAYS; + + +public class CalendarManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CalendarCampaign.class); + + final private static Map calendarCampaigns = new THashMap<>(); + public static double HC_MODIFIER; + + public CalendarManager() { + long millis = System.currentTimeMillis(); + this.reload(); + LOGGER.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis)); + } + + public void dispose(){ + calendarCampaigns.clear(); + } + + public boolean reload() { + this.dispose(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_campaigns WHERE enabled = 1")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + calendarCampaigns.put(set.getInt("id"), new CalendarCampaign(set)); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + return false; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + CalendarCampaign campaign = calendarCampaigns.get(set.getInt("campaign_id")); + if(campaign != null){ + campaign.addReward(new CalendarRewardObject(set)); + } + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + return false; + } + + HC_MODIFIER = Emulator.getConfig().getDouble("hotel.calendar.pixels.hc_modifier", 2.0); + + return true; + } + + public void addCampaign(CalendarCampaign campaign) { + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_campaigns ( name, image, start_timestamp, total_days, lock_expired) VALUES (?, ?, ?, ? , ?)", Statement.RETURN_GENERATED_KEYS)) { + statement.setString(1, campaign.getName()); + statement.setString(2, campaign.getImage()); + statement.setTimestamp(3, campaign.getStartTimestamp()); + statement.setInt(4, campaign.getTotalDays()); + statement.setBoolean(5, campaign.getLockExpired()); + int affectedRows = statement.executeUpdate(); + + if (affectedRows == 0) { + throw new SQLException("Creating calendar campaign failed, no rows affected."); + } + + try (ResultSet generatedKeys = statement.getGeneratedKeys()) { + if (generatedKeys.next()) { + campaign.setId(generatedKeys.getInt(1)); + } else { + throw new SQLException("Creating calendar campaign failed, no ID found."); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + + calendarCampaigns.put(campaign.getId(), campaign); + } + + public boolean deleteCampaign(CalendarCampaign campaign) { + calendarCampaigns.remove(campaign.getId()); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM calendar_campaigns WHERE id = ? LIMIT 1")) { + statement.setInt(1, campaign.getId()); + return statement.execute(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + + return false; + } + + public CalendarCampaign getCalendarCampaign(String campaignName) { + return calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null); + } + public Map getCalendarCampaigns() { + return calendarCampaigns; + } + + public void claimCalendarReward(Habbo habbo, String campaignName, int day, boolean force) { + CalendarCampaign campaign = calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null); + if(campaign == null) return; + if (habbo.getHabboStats().calendarRewardsClaimed.stream().noneMatch(claimed -> claimed.getCampaignId() == campaign.getId() && claimed.getDay() == day)) { + + Set keys = campaign.getRewards().keySet(); + Map rewards = new THashMap<>(); + if(keys.isEmpty()) return; + keys.forEach(key -> rewards.put(rewards.size() + 1, key)); + int rand = Emulator.getRandom().nextInt(rewards.size() - 1 + 1) + 1; + int random = rewards.get(rand); + CalendarRewardObject object = campaign.getRewards().get(random); + if (object == null) return; + int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + if(daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) { + int diff = (daysBetween - day); + if ((((diff <= 2 || !campaign.getLockExpired()) && diff >= 0) || (force && habbo.hasPermission("acc_calendar_force")))) { + + if (Emulator.getPluginManager().fireEvent(new UserClaimRewardEvent(habbo, campaign, day, object, force)).isCancelled()) { + return; + } + + habbo.getHabboStats().calendarRewardsClaimed.add(new CalendarRewardClaimed(habbo.getHabboInfo().getId(), campaign.getId(), day, object.getId(), new Timestamp(System.currentTimeMillis()))); + habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object, habbo)); + object.give(habbo); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, campaign_id, day, reward_id, timestamp) VALUES (?, ?, ?, ?, ?)")) { + statement.setInt(1, habbo.getHabboInfo().getId()); + statement.setInt(2, campaign.getId()); + statement.setInt(3, day); + statement.setInt(4, object.getId()); + statement.setTimestamp(5, new Timestamp(System.currentTimeMillis())); + statement.execute(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + } + } + } + } +} + diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java new file mode 100644 index 00000000..3cc0c56d --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java @@ -0,0 +1,50 @@ +package com.eu.habbo.habbohotel.campaign.calendar; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; + +public class CalendarRewardClaimed { + private final int user_id; + private final int campaign; + private final int day; + private final int reward_id; + private final Timestamp timestamp; + + public CalendarRewardClaimed(ResultSet set) throws SQLException { + this.user_id = set.getInt("user_id"); + this.campaign = set.getInt("campaign_id"); + this.day = set.getInt("day"); + this.reward_id = set.getInt("reward_id"); + this.timestamp = set.getTimestamp("timestamp"); + } + + public CalendarRewardClaimed(int user_id, int campaign, int day, int reward_id, Timestamp timestamp) { + this.user_id = user_id; + this.campaign = campaign; + this.day = day; + this.reward_id = reward_id; + this.timestamp = timestamp; + } + + public int getUserId() { + return this.user_id; + } + + public int getCampaignId() { + return this.campaign; + } + + public int getDay() { + return this.day; + } + + public int getRewardId() { + return this.reward_id; + } + + public Timestamp getTimestamp() { + return this.timestamp; + } + +} diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardObject.java similarity index 59% rename from src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java rename to src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardObject.java index f2b135b5..efe8f91d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardObject.java @@ -1,32 +1,47 @@ -package com.eu.habbo.habbohotel.catalog; +package com.eu.habbo.habbohotel.campaign.calendar; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.subscriptions.Subscription; +import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class CalendarRewardObject { + private static final Logger LOGGER = LoggerFactory.getLogger(CalendarRewardObject.class); + private final int id; + private final String productName; private final String customImage; private final int credits; + private final int pixels; private final int points; private final int pointsType; private final String badge; private final int itemId; + private final String subscription_type; + private final int subscription_days; public CalendarRewardObject(ResultSet set) throws SQLException { this.id = set.getInt("id"); + this.productName = set.getString("product_name"); this.customImage = set.getString("custom_image"); this.credits = set.getInt("credits"); + this.pixels = set.getInt("pixels"); this.points = set.getInt("points"); this.pointsType = set.getInt("points_type"); this.badge = set.getString("badge"); this.itemId = set.getInt("item_id"); + this.subscription_type = set.getString("subscription_type"); + this.subscription_days = set.getInt("subscription_days"); } public void give(Habbo habbo) { @@ -34,6 +49,10 @@ public class CalendarRewardObject { habbo.giveCredits(this.credits); } + if (this.pixels > 0) { + habbo.givePixels((int)(this.pixels * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0))); + } + if (this.points > 0) { habbo.givePoints(this.pointsType, this.points); } @@ -42,6 +61,14 @@ public class CalendarRewardObject { habbo.addBadge(this.badge); } + if(this.subscription_type != null && !this.subscription_type.isEmpty()) { + if ("HABBO_CLUB".equals(this.subscription_type)) { + habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, this.subscription_days * 86400); + } else { + habbo.getHabboStats().createSubscription(this.subscription_type, this.subscription_days * 86400); + } + } + if (this.itemId > 0) { Item item = getItem(); @@ -71,6 +98,9 @@ public class CalendarRewardObject { return this.credits; } + public int getPixels() { + return this.pixels; + } public int getPoints() { return this.points; } @@ -79,6 +109,18 @@ public class CalendarRewardObject { return this.pointsType; } + public String getProductName() { + return productName; + } + + public String getSubscriptionType() { + return subscription_type; + } + + public int getSubscriptionDays() { + return subscription_days; + } + public String getBadge() { return this.badge; } @@ -86,4 +128,5 @@ public class CalendarRewardObject { public Item getItem() { return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId); } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 5058b78c..a48aad2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject; import com.eu.habbo.habbohotel.catalog.layouts.*; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.guilds.Guild; @@ -190,7 +191,6 @@ public class CatalogManager { public final TIntIntHashMap offerDefs; public final Item ecotronItem; public final THashMap limitedNumbers; - public final THashMap calendarRewards; private final List vouchers; public CatalogManager() { @@ -207,7 +207,6 @@ public class CatalogManager { this.offerDefs = new TIntIntHashMap(); this.vouchers = new ArrayList<>(); this.limitedNumbers = new THashMap<>(); - this.calendarRewards = new THashMap<>(); this.initialize(); @@ -230,7 +229,6 @@ public class CatalogManager { this.loadClothing(); this.loadRecycler(); this.loadGiftWrappers(); - this.loadCalendarRewards(); } private synchronized void loadLimitedNumbers() { @@ -482,23 +480,6 @@ public class CatalogManager { } } - private void loadCalendarRewards() { - synchronized (this.calendarRewards) { - this.calendarRewards.clear(); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) { - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - this.calendarRewards.put(set.getInt("id"), new CalendarRewardObject(set)); - } - } - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - } - } - } - - private void loadClothing() { synchronized (this.clothing) { this.clothing.clear(); @@ -1178,28 +1159,6 @@ public class CatalogManager { return offers; } - public void claimCalendarReward(Habbo habbo, int day, boolean force) { - if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) { - CalendarRewardObject object = this.calendarRewards.get((day+1)); - int actualDay = (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400); - int diff = (actualDay - day); - if (((diff <= 2 && diff >= 0) || force) && object != null) { - habbo.getHabboStats().calendarRewardsClaimed.add(day); - habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object)); - object.give(habbo); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) { - statement.setInt(1, habbo.getHabboInfo().getId()); - statement.setInt(2, day); - statement.setInt(3, Emulator.getIntUnixTimestamp()); - statement.execute(); - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - } - } - } - } - public TargetOffer getTargetOffer(int offerId) { return this.targetOffers.get(offerId); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java index 5d996740..ea9d3c69 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java @@ -1,10 +1,17 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer; import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; +import java.sql.Timestamp; +import java.time.Duration; +import java.util.Date; + +import static java.time.temporal.ChronoUnit.DAYS; + public class CalendarCommand extends Command { public CalendarCommand() { super("cmd_calendar", Emulator.getTexts().getValue("commands.keys.cmd_calendar").split(";")); @@ -13,8 +20,17 @@ public class CalendarCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { - gameClient.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, true)); - gameClient.sendResponse(new NuxAlertComposer("openView/calendar")); + String campaignName = Emulator.getConfig().getValue("hotel.calendar.default"); + + if(params.length > 1 && gameClient.getHabbo().hasPermission("cmd_calendar_staff")) { + campaignName = params[1]; + } + CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName); + if(campaign == null) return false; + int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + if(daysBetween >= 0) { + gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); + } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java index a37d9482..64dd09d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -275,6 +275,7 @@ public class CommandHandler { addCommand(new UnmuteCommand()); addCommand(new UpdateAchievements()); addCommand(new UpdateBotsCommand()); + addCommand(new UpdateCalendarCommand()); addCommand(new UpdateCatalogCommand()); addCommand(new UpdateConfigCommand()); addCommand(new UpdateGuildPartsCommand()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java new file mode 100644 index 00000000..a110c20b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java @@ -0,0 +1,21 @@ +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.messages.outgoing.catalog.*; +import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; + +public class UpdateCalendarCommand extends Command { + + public UpdateCalendarCommand() { + super("cmd_update_calendar", Emulator.getTexts().getValue("commands.keys.cmd_update_calendar").split(";")); + } + + @Override + public boolean handle(GameClient gameClient, String[] params) { + Emulator.getGameEnvironment().getCalendarManager().reload(); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.cmd_update_calendar"), RoomChatMessageBubbles.ALERT); + return true; + } +} 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 4463148f..64747a29 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardClaimed; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementManager; @@ -33,7 +34,7 @@ public class HabboStats implements Runnable { public final TIntArrayList secretRecipes; public final HabboNavigatorWindowSettings navigatorWindowSettings; public final THashMap cache; - public final TIntArrayList calendarRewardsClaimed; + public final ArrayList calendarRewardsClaimed; public final TIntObjectMap offerCache = new TIntObjectHashMap<>(); private final AtomicInteger lastOnlineTime = new AtomicInteger(Emulator.getIntUnixTimestamp()); private final THashMap achievementProgress; @@ -109,7 +110,7 @@ public class HabboStats implements Runnable { this.ignoredUsers = new TIntArrayList(0); this.roomsVists = new TIntArrayList(0); this.secretRecipes = new TIntArrayList(0); - this.calendarRewardsClaimed = new TIntArrayList(0); + this.calendarRewardsClaimed = new ArrayList<>(); this.habboInfo = habboInfo; @@ -206,7 +207,7 @@ public class HabboStats implements Runnable { calendarRewardsStatement.setInt(1, this.habboInfo.getId()); try (ResultSet rewardSet = calendarRewardsStatement.executeQuery()) { while (rewardSet.next()) { - this.calendarRewardsClaimed.add(rewardSet.getInt("reward_id")); + this.calendarRewardsClaimed.add(new CalendarRewardClaimed(rewardSet)); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java index 1ab77c2c..bca8c1de 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java @@ -6,9 +6,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class AdventCalendarForceOpenEvent extends MessageHandler { @Override public void handle() throws Exception { - String campaign = this.packet.readString(); + String campaignName = this.packet.readString(); int day = this.packet.readInt(); - Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, true); + Emulator.getGameEnvironment().getCalendarManager().claimCalendarReward(this.client.getHabbo(), campaignName, day, true); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java index 9c68cfd0..58970271 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java @@ -6,9 +6,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class AdventCalendarOpenDayEvent extends MessageHandler { @Override public void handle() throws Exception { - String campaign = this.packet.readString(); + String campaignName = this.packet.readString(); int day = this.packet.readInt(); - Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, false); + Emulator.getGameEnvironment().getCalendarManager().claimCalendarReward(this.client.getHabbo(), campaignName, day, false); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java index aa4d946f..3636c6c0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign; import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer; @@ -11,9 +12,14 @@ import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.Timestamp; +import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Date; +import java.util.concurrent.TimeUnit; + +import static java.time.temporal.ChronoUnit.DAYS; public class UsernameEvent extends MessageHandler { @Override @@ -24,7 +30,7 @@ public class UsernameEvent extends MessageHandler { calendar = true; } else { - long daysBetween = ChronoUnit.DAYS.between(new Date((long) this.client.getHabbo().getHabboInfo().getLastOnline() * 1000L).toInstant(), new Date().toInstant()); + long daysBetween = DAYS.between(new Date((long) this.client.getHabbo().getHabboInfo().getLastOnline() * 1000L).toInstant(), new Date().toInstant()); Date lastLogin = new Date(this.client.getHabbo().getHabboInfo().getLastOnline()); @@ -84,8 +90,14 @@ public class UsernameEvent extends MessageHandler { } if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { - this.client.sendResponse(new AdventCalendarDataComposer("xmas15", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true)); - this.client.sendResponse(new NuxAlertComposer("openView/calendar")); + CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(Emulator.getConfig().getValue("hotel.calendar.default")); + if(campaign != null){ + long daysBetween = DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + if(daysBetween >= 0) { + this.client.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); + this.client.sendResponse(new NuxAlertComposer("openView/calendar")); + } + }; } if (TargetOffer.ACTIVE_TARGET_OFFER_ID > 0) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java index 82c512f2..abf20a7a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java @@ -1,20 +1,24 @@ package com.eu.habbo.messages.outgoing.events.calendar; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardClaimed; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.list.array.TIntArrayList; -import gnu.trove.procedure.TIntProcedure; + +import java.util.ArrayList; public class AdventCalendarDataComposer extends MessageComposer { private final String eventName; + private final String campaignImage; private final int totalDays; private final int currentDay; - private final TIntArrayList unlocked; + private final ArrayList unlocked; private final boolean lockExpired; - public AdventCalendarDataComposer(String eventName, int totalDays, int currentDay, TIntArrayList unlocked, boolean lockExpired) { + public AdventCalendarDataComposer(String eventName, String campaignImage, int totalDays, int currentDay, ArrayList unlocked, boolean lockExpired) { this.eventName = eventName; + this.campaignImage = campaignImage; this.totalDays = totalDays; this.currentDay = currentDay; this.unlocked = unlocked; @@ -25,23 +29,23 @@ public class AdventCalendarDataComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.AdventCalendarDataComposer); this.response.appendString(this.eventName); - this.response.appendString(""); + this.response.appendString(this.campaignImage); this.response.appendInt(this.currentDay); this.response.appendInt(this.totalDays); this.response.appendInt(this.unlocked.size()); TIntArrayList expired = new TIntArrayList(); - for (int i = 0; i < this.totalDays; i++) { + if (this.lockExpired) { for (int i = 0; i < this.totalDays; i++) { expired.add(i); } + } expired.remove(this.currentDay); if(this.currentDay > 1) expired.remove(this.currentDay - 2); if(this.currentDay > 0) expired.remove(this.currentDay - 1); - this.unlocked.forEach(value -> { - AdventCalendarDataComposer.this.response.appendInt(value); - expired.remove(value); - return true; + this.unlocked.forEach(claimed -> { + AdventCalendarDataComposer.this.response.appendInt(claimed.getDay()); + expired.remove(claimed.getDay()); }); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java index 999eefbb..fb23b318 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java @@ -1,7 +1,9 @@ package com.eu.habbo.messages.outgoing.events.calendar; -import com.eu.habbo.habbohotel.catalog.CalendarRewardObject; -import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -9,19 +11,39 @@ import com.eu.habbo.messages.outgoing.Outgoing; public class AdventCalendarProductComposer extends MessageComposer { public final boolean visible; public final CalendarRewardObject rewardObject; + public final Habbo habbo; - public AdventCalendarProductComposer(boolean visible, CalendarRewardObject rewardObject) { + public AdventCalendarProductComposer(boolean visible, CalendarRewardObject rewardObject, Habbo habbo) { this.visible = visible; this.rewardObject = rewardObject; + this.habbo = habbo; } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.AdventCalendarProductComposer); this.response.appendBoolean(this.visible); - this.response.appendString(this.rewardObject.getItem().getName()); + + String className = ""; + String productName = this.rewardObject.getProductName() + .replace("%credits%", String.valueOf(this.rewardObject.getCredits())) + .replace("%pixels%", String.valueOf((int) (this.rewardObject.getPixels() * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0)))) + .replace("%points%", String.valueOf(this.rewardObject.getPoints())) + .replace("%points_type%", String.valueOf(this.rewardObject.getPointsType())) + .replace("%badge%", this.rewardObject.getBadge()); + if(this.rewardObject.getSubscriptionType() != null){ + productName = productName.replace("%subscription_type%", this.rewardObject.getSubscriptionType()).replace("%subscription_days%", String.valueOf(this.rewardObject.getSubscriptionDays())); + } + + if(this.rewardObject.getItem() != null){ + productName = productName.replace("%item%", this.rewardObject.getItem().getName()); + className = this.rewardObject.getItem().getName(); + } + + this.response.appendString(productName); this.response.appendString(this.rewardObject.getCustomImage()); - this.response.appendString(this.rewardObject.getItem().getName()); + this.response.appendString(className); + return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java new file mode 100644 index 00000000..c57f60db --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java @@ -0,0 +1,23 @@ +package com.eu.habbo.plugin.events.users.calendar; + +import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.plugin.events.users.UserEvent; + +public class UserClaimRewardEvent extends UserEvent { + + public CalendarCampaign campaign; + public int day; + public CalendarRewardObject reward; + public boolean force; + + public UserClaimRewardEvent(Habbo habbo, CalendarCampaign campaign, int day, CalendarRewardObject reward, boolean force) { + super(habbo); + + this.campaign = campaign; + this.day = day; + this.reward = reward; + this.force = force; + } +} From 4e1c240db4cd3e22061e16369cb31ee0126058e0 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Wed, 2 Mar 2022 20:08:34 -0300 Subject: [PATCH 42/94] Update 3_0_0 to 3_0_1.sql --- sqlupdates/3_0_0 to 3_0_1.sql | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 4a1d34e7..a493191f 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -5,3 +5,55 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk. -- Enable or Disable TTY in console (Default is enabled) INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1'); + + -- ---------------------------- +-- Table structure for calendar_campaigns +-- ---------------------------- +DROP TABLE IF EXISTS `calendar_campaigns`; +CREATE TABLE `calendar_campaigns` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', + `start_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `total_days` int NOT NULL DEFAULT '30', + `lock_expired` enum('1','0') NOT NULL DEFAULT '1', + `enabled` enum('1','0') NOT NULL DEFAULT '1', + UNIQUE KEY `id` (`id`) +); + +-- ---------------------------- +-- Records of calendar_campaigns +-- ---------------------------- +INSERT INTO `calendar_campaigns` VALUES ('1', 'test', '', '2022-02-09 16:49:13', '31', '1', '1'); + +-- ---------------------------- +-- Table structure for calendar_rewards +-- ---------------------------- +DROP TABLE IF EXISTS `calendar_rewards`; +CREATE TABLE `calendar_rewards` ( + `id` int NOT NULL AUTO_INCREMENT, + `campaign_id` int NOT NULL DEFAULT '0', + `product_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `credits` int NOT NULL DEFAULT '0', + `pixels` int NOT NULL DEFAULT '0', + `points` int NOT NULL DEFAULT '0', + `points_type` int NOT NULL DEFAULT '0', + `badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `item_id` int NOT NULL DEFAULT '0', + `subscription_type` enum('HABBO_CLUB') CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL, + `subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '', + `subscription_days` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) USING BTREE +); +@ -92,11 +92,12 @@ +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.default', 'test'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.pixels.hc_modifier', '2.0'); + +-- Calendar force open +ALTER TABLE `permissions` ADD COLUMN `acc_calendar_force` enum('0','1') NULL DEFAULT '0'; + +-- UpdateCalendar command. +ALTER TABLE `permissions` ADD `cmd_update_calendar` ENUM('0', '1') NOT NULL DEFAULT '0'; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_update_calendar', ':update_calendar'), ('commands.keys.cmd_update_calendar', 'update_calendar'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.success.cmd_update_calendar', 'Calendar updated successfully!'); \ No newline at end of file From c4342e20af35ae843e29c7ab8f7a46e35c7fe755 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Thu, 3 Mar 2022 16:05:43 -0300 Subject: [PATCH 43/94] fix trophies --- sqlupdates/3_0_0 to 3_0_1.sql | 2 ++ .../java/com/eu/habbo/habbohotel/catalog/CatalogManager.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 9cbec636..18fdd983 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -8,3 +8,5 @@ INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1'); -- Youtube Api v3 key to YoutubeManager INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('youtube.apikey', ''); + +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.trophies.length.max', '300'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 6eb01a77..93547337 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -1002,6 +1002,10 @@ public class CatalogManager { extradata = "UMAD"; } + if (extradata.length() > Emulator.getConfig().getInt("hotel.trophies.length.max", 300)) { + extradata = extradata.substring(0, Emulator.getConfig().getInt("hotel.trophies.length.max", 300)); + } + extradata = habbo.getClient().getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + Emulator.getGameEnvironment().getWordFilter().filter(extradata.replace(((char) 9) + "", ""), habbo); } From e6c1766c2c1d480f9b06590271ebbb3bf37285d7 Mon Sep 17 00:00:00 2001 From: brenoepic Date: Thu, 3 Mar 2022 22:27:30 +0000 Subject: [PATCH 44/94] Fix pressure plates --- .../items/interactions/InteractionPressurePlate.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java index 06d19289..b446e6f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java @@ -37,7 +37,7 @@ public class InteractionPressurePlate extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); + } @Override @@ -66,6 +66,11 @@ public class InteractionPressurePlate extends InteractionDefault { updateState(room); } + @Override + public void onPickUp(Room room) { + this.setExtradata("0"); + } + public void updateState(Room room) { boolean occupied = false; From a08f1d1b8a55abd936ec1f3930e28c9262376c2d Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Fri, 4 Mar 2022 21:40:13 -0300 Subject: [PATCH 45/94] Update RoomPickupItemEvent.java --- .../messages/incoming/rooms/items/RoomPickupItemEvent.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java index fe4ab2c9..c3585ecb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPickupItemEvent.java @@ -9,7 +9,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class RoomPickupItemEvent extends MessageHandler { @Override public void handle() throws Exception { - int unknown = this.packet.readInt(); + int category = this.packet.readInt(); //10 = floorItem and 20 = wallItem int itemId = this.packet.readInt(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); @@ -31,6 +31,8 @@ public class RoomPickupItemEvent extends MessageHandler { if (room.hasRights(this.client.getHabbo())) { if (this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { item.setUserId(this.client.getHabbo().getHabboInfo().getId()); + } else if (this.client.getHabbo().getHabboInfo().getId() != room.getOwnerId() && item.getUserId() == room.getOwnerId()) { + return; } room.ejectUserItem(item); From c7ed4a88c246eba8d30b106670201d6bfb13e337 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Sat, 5 Mar 2022 23:17:27 -0300 Subject: [PATCH 46/94] ejectUserFurni on remove rights --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 5e87ce8e..932f149a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3962,7 +3962,6 @@ public class Room implements Comparable, ISerialize, Runnable { return; this.sendComposer(new RoomRemoveRightsListComposer(this, userId).compose()); - if (this.rights.remove(userId)) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) { statement.setInt(1, this.id); @@ -3974,6 +3973,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (habbo != null) { + this.ejectUserFurni(habbo.getHabboInfo().getId()); habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE); habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL); this.refreshRightsForHabbo(habbo); @@ -3981,6 +3981,10 @@ public class Room implements Comparable, ISerialize, Runnable { } public void removeAllRights() { + for (int userId : rights.toArray()) { + this.ejectUserFurni(userId); + } + this.rights.clear(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ?")) { From b28bf5f4ef97ec9b739646acd9f00ebe2b0c3dc5 Mon Sep 17 00:00:00 2001 From: brenoepic Date: Sun, 6 Mar 2022 02:22:05 +0000 Subject: [PATCH 47/94] Update Room.java --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 1 + 1 file changed, 1 insertion(+) 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 932f149a..af82a1ae 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3962,6 +3962,7 @@ public class Room implements Comparable, ISerialize, Runnable { return; this.sendComposer(new RoomRemoveRightsListComposer(this, userId).compose()); + if (this.rights.remove(userId)) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) { statement.setInt(1, this.id); From aff5566451613bdf156f78d6ba2267185264586f Mon Sep 17 00:00:00 2001 From: brenoepics Date: Mon, 7 Mar 2022 01:46:12 +0000 Subject: [PATCH 48/94] Fix exception on answering polls without an answer --- .../eu/habbo/messages/incoming/polls/AnswerPollEvent.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index 574e50ca..4a3b11fb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -21,12 +21,15 @@ public class AnswerPollEvent extends MessageHandler { int pollId = this.packet.readInt(); int questionId = this.packet.readInt(); int count = this.packet.readInt(); - + String answers = this.packet.readString(); + StringBuilder answer = new StringBuilder(); for (int i = 0; i < count; i++) { - answer.append(":").append(this.packet.readString()); + answer.append(":").append(answers); } + if(answer.length() <= 0) return; + if (pollId == 0 && questionId <= 0) { this.client.getHabbo().getHabboInfo().getCurrentRoom().handleWordQuiz(this.client.getHabbo(), answer.toString()); return; From 0a5c4dd57eb5d5c72cfeef63398677921d7537ac Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Sun, 13 Mar 2022 16:34:22 +0000 Subject: [PATCH 49/94] Receiving Habbo of Hand Item, should Turn Towards Sender. --- .../eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java index 3c29ee52..16a59ec5 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/HabboGiveHandItemToHabbo.java @@ -26,6 +26,8 @@ public class HabboGiveHandItemToHabbo implements Runnable { if (itemId > 0) { this.from.getRoomUnit().setHandItem(0); this.from.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserHandItemComposer(this.from.getRoomUnit()).compose()); + this.target.getRoomUnit().lookAtPoint(this.from.getRoomUnit().getCurrentLocation()); + this.target.getRoomUnit().statusUpdate(true); this.target.getClient().sendResponse(new RoomUserReceivedHandItemComposer(this.from.getRoomUnit(), itemId)); this.target.getRoomUnit().setHandItem(itemId); this.target.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserHandItemComposer(this.target.getRoomUnit()).compose()); From b2fb96fde7b92d21bfcd68afd92ce5bbcfb870ac Mon Sep 17 00:00:00 2001 From: brenoepics Date: Thu, 17 Mar 2022 11:51:43 +0000 Subject: [PATCH 50/94] Add gift message max lenght and npe fixes --- sqlupdates/3_0_0 to 3_0_1.sql | 2 ++ .../incoming/catalog/CatalogBuyItemAsGiftEvent.java | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 9cbec636..71ab3129 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -8,3 +8,5 @@ INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1'); -- Youtube Api v3 key to YoutubeManager INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('youtube.apikey', ''); + +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.gifts.length.max', '300'); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index 13ffb72a..d4093075 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -80,6 +80,10 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { return; } + if (message.length() > Emulator.getConfig().getInt("hotel.gifts.length.max", 300)) { + message = message.substring(0, Emulator.getConfig().getInt("hotel.gifts.length.max", 300)); + } + Integer iItemId = Emulator.getGameEnvironment().getCatalogManager().giftWrappers.get(spriteId); if (iItemId == null) @@ -172,7 +176,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { int limitedNumber = 0; if (item.isLimited()) { count = 1; - if (Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(item).available() == 0) { + if (Emulator.getGameEnvironment().getCatalogManager().getLimitedConfig(item).available() == 0 && habbo != null) { habbo.getClient().sendResponse(new AlertLimitedSoldOutComposer()); return; } @@ -269,7 +273,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { return; } else { if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) { - if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) { + if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && habbo != null && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) { ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extraData)); extraData = "UMAD"; } From ddef2543fea13a3f5b36efe4bef6247b78c44eab Mon Sep 17 00:00:00 2001 From: Snaiker Date: Fri, 18 Mar 2022 02:46:18 +0000 Subject: [PATCH 51/94] Fix issue NPE --- .../subscriptions/SubscriptionHabboClub.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java index 66c3d041..0c7fc193 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java @@ -15,6 +15,8 @@ import com.eu.habbo.messages.outgoing.generic.PickMonthlyClubGiftNotificationCom import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.*; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -29,6 +31,7 @@ import java.util.TreeMap; * @author Beny */ public class SubscriptionHabboClub extends Subscription { + private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionHabboClub.class); public static boolean HC_PAYDAY_ENABLED = false; public static int HC_PAYDAY_NEXT_DATE = Integer.MAX_VALUE; // yyyy-MM-dd HH:mm:ss @@ -393,9 +396,18 @@ public class SubscriptionHabboClub extends Subscription { break; default: - pointCurrency = Integer.parseInt(currency); - habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); - habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); + pointCurrency = -1; + try { + pointCurrency = Integer.parseInt(currency); + } + catch (NumberFormatException ex) { + LOGGER.error("Couldn't convert the type point currency {} on HC PayDay. The number must be a integer and positive.", pointCurrency); + } + + if (pointCurrency >= 0) { + habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); + habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); + } break; } From a26e8c09bd0264a1a93868c75dc9b46d4b887b02 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 18 Mar 2022 21:06:52 +0000 Subject: [PATCH 52/94] Update README.md --- README.md | 160 +++++++++++++++++++++++++++++------------------------- 1 file changed, 87 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index bff62d04..bd2e1303 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,59 @@ # Arcturus Morningstar # -## What is Arcturus Morningstar? ## -Arcturus Morningstar is the community project for the Arcturus Emulator by TheGeneral. - -The community project was made because the Arcturus Emulator has been abandoned by TheGeneral with lack of updates, an intent to monetize the project, and make the project private. - -TheGeneral's own words were "dont like it then dont use it". We did not like what he was doing, so we made our own version. - -## License ## -Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). - -## Versions ## -[![image](https://img.shields.io/badge/VERSION-3.0.0-success.svg?style=for-the-badge&logo=appveyor)](#) -[![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor)](#) -[![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=DISCORD&logoColor=fff)](https://discord.gg/BzfFsTp) - -Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/-/releases - -Client build: **PRODUCTION-201611291003-338511768** - -## Reporting problems ## -You can report problems via the Issue Tracker at https://git.krews.org/morningstar/Arcturus-Community/issues -When making an bug report or a feature request use the template we provide so that it can be categorized correctly and we have more information to replicate a bug or implement a feature correctly. - -## Credits ## -- TheGeneral -- Beny -- Alejandro -- Capheus -- Skeletor -- Harmonic -- Mike -- Remco -- zGrav -- Quadral -- Harmony -- Swirny -- ArpyAge -- Mikkel -- Rodolfo -- Rasmus -- Kitt Mustang -- Snaiker -- nttzx -- necmi -- Dome -- Jose Flores -- Cam -- Oliver -- Narzo -- Tenshie -- MartenM -- Ridge -- SenpaiDipper -- Snaiker -- Thijmen +Arcturus Morningstar is as a fork of Arcturus Emulator by TheGeneral. Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt) and is developed for free by talented developers at Krews.org and is compatible with the following client revision/community projects: -## Discord ## -Join us on Discord at https://discord.gg/BzfFsTp +| Flash | Community Clients | +| ------------- | ------------- | +| [PRODUCTION-201611291003-338511768](https://git.krews.org/morningstar/apollyon/uploads/dc669a26613bf2356e48eb653734ab29/patched-habbo.swf) | Nitro (Recommended)* | + +###### *Note to use Nitro you will need to use the following [plugin](https://git.krews.org/nitro/ms-websockets/-/releases) with Arcturus Morningstar ####### -## Contributing ## -Anyone is allowed to fork the project and make pull requests. We make no guarantee that pull requests will be approved into the project. -## Branches ## -There will be 2 branches of the Arcturus Morningstar emulator: -`master` - The master branch will be the stable branch. Everything here has been tested on a live hotel and contains no known problems. -`dev` - The dev branch will be the unstable branch. This one is the most up to date, but things may not work as intended. -There is no set timeframe on when new versions will be released or when the stable branch will be updated. +[![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=KREWS&logoColor=fff)](https://discord.gg/BzfFsTp) -## Custom features ## -Do not implement custom features into the source. -A custom feature will be defined as a feature or ability which is not possible in Habbo.com -Use plugins for custom features, and if a plugin is not possible, you should adapt the source to enable plugins to do that. +## Download ## +[![image](https://img.shields.io/badge/STABLE%20RELEASES-3.0.0-success.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/releases) -## Why always make things as plugins? ## -Why always make things as plugins? +[![image](https://img.shields.io/badge/DEVELOPER%20BUILDS-3.1.0-red.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/jobs) * + +[![image](https://img.shields.io/badge/RECOMMENDED%20PLUGINS-blue.svg?style=for-the-badge&logo=)](https://git.krews.org/official-plugins) + +###### * Note to use these builds you will need to run any database updates from [here](https://git.krews.org/morningstar/Arcturus-Community/-/tree/dev/sqlupdates) ####### + + +### Branches ### +There are two main branches in use on the Arcturus Morningstar git. Below the pros an + +| master | Tested on a production hotel and is stable for every day use with no known serious exploits. | +| ------------- | ------------- | + +| dev | The most up-to-date, but features may not work as intended. | +| ------------- | ------------- | + + + + +There is no set timeframe on when new versions will be released or when the stable branch will be updated + + +## Can I Help!? ## +#### Reporting Bugs: #### +You can report problems via the [Issue Tracker](https://git.krews.org/morningstar/Arcturus-Community/issues)* +###### * When making an bug report or a feature request use the template we provide so that it can be categorized correctly and we have more information to replicate a bug or implement a feature correctly. ###### +#### Can I contribute code to this project? #### +Of Course! if you have fixed a bug from the git please feel free to do a [merge request](https://git.krews.org/morningstar/Arcturus-Community/issues)* +###### * Anyone is allowed to fork the project and make pull requests, we make no guarantee that pull requests will be approved into the project. Please Do NOT push code which does not replicate behaviour on habbo.com, instead make the behaviour configurable or as a plugin. ###### + + + +## Plugin System ## +The robust Plugin System included in the original Arcturus release is also included in Arcturus Morningstar, if you're interested in making your own plugins, feel free to ask around on our discord and we'll point you in the right direction! + +A lot of the community aren't used to modifying things in this way, so we've written a few pros: 1. Other people will see that plugins are the normal way of adding custom features 2. Plugins can be added and removed at the hotel owner's choice, it makes customizing the hotel easier 3. Developers will be able to read plugin source code to learn how to make their own plugins, without the need to look in complicated source code @@ -91,8 +66,47 @@ Sale of a special edition of a *source code* will not be permitted. You may use If we ever are to make paid features or plugins, we will not prevent or discourage developers from creating alternative options for users. -## Plugins - Official Plugins ## -You can find official plugins to add custom features to Arcturus Morningstar at the following URL: -[View the respository here.](https://git.krews.org/official-plugins) + + + +### Credits ### + + - TheGeneral (Arcturus Emulator) + - Beny + - Alejandro + - Capheus + - Skeletor + - Harmonic + - Mike + - Remco + - zGrav + - Quadral + - Harmony + - Swirny + - ArpyAge + - Mikkel + - Rodolfo + - Rasmus + - Kitt Mustang + - Snaiker + - nttzx + - necmi + - Dome + - Jose Flores + - Cam + - Oliver + - Narzo + - Tenshie + - MartenM + - Ridge + - SenpaiDipper + - Snaiker + - Thijmen + - Brenoepic + - Stankman + + + + From e403462419116c452e64fcf23c79a395e42070f9 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Fri, 18 Mar 2022 21:10:18 +0000 Subject: [PATCH 53/94] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index bd2e1303..877e6bfb 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Arcturus Morningstar is as a fork of Arcturus Emulator by TheGeneral. Arcturus M | Flash | Community Clients | | ------------- | ------------- | -| [PRODUCTION-201611291003-338511768](https://git.krews.org/morningstar/apollyon/uploads/dc669a26613bf2356e48eb653734ab29/patched-habbo.swf) | Nitro (Recommended)* | +| [PRODUCTION-201611291003-338511768](https://git.krews.org/morningstar/apollyon/uploads/dc669a26613bf2356e48eb653734ab29/patched-habbo.swf) | [Nitro (Recommended)*](https://git.krews.org/nitro) | ###### *Note to use Nitro you will need to use the following [plugin](https://git.krews.org/nitro/ms-websockets/-/releases) with Arcturus Morningstar ####### @@ -101,7 +101,6 @@ If we ever are to make paid features or plugins, we will not prevent or discoura - MartenM - Ridge - SenpaiDipper - - Snaiker - Thijmen - Brenoepic - Stankman From 5d82a6e42653ce044d0853f095569b28c8601869 Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 17:26:43 -0500 Subject: [PATCH 54/94] remove forced room forwarding to home room --- .../habbo/messages/incoming/users/RequestUserDataEvent.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java index f4d37e90..aa55bd84 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java @@ -43,11 +43,6 @@ public class RequestUserDataEvent extends MessageHandler { messages.add(new UserDataComposer(this.client.getHabbo()).compose()); messages.add(new UserPerksComposer(this.client.getHabbo()).compose()); - if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) - messages.add(new ForwardToRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); - else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) - messages.add(new ForwardToRoomComposer(RoomManager.HOME_ROOM_ID).compose()); - messages.add(new MeMenuSettingsComposer(this.client.getHabbo()).compose()); From 5093d6c74597bd562326c0723deaca629e32d6bd Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 17:27:44 -0500 Subject: [PATCH 55/94] remove some packets from being sent at login --- .../incoming/handshake/SecureLoginEvent.java | 13 ++----------- .../navigator/RequestNewNavigatorDataEvent.java | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) 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 fbde40cb..dca9c53a 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 @@ -73,9 +73,7 @@ public class SecureLoginEvent extends MessageHandler { if (sso.isEmpty()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - if (Emulator.getConfig().getBoolean("debug.mode")) { - LOGGER.warn("Client is trying to connect without SSO ticket! Closed connection..."); - } + LOGGER.debug("Client is trying to connect without SSO ticket! Closed connection..."); return; } @@ -146,16 +144,9 @@ public class SecureLoginEvent extends MessageHandler { this.client.sendResponses(messages); //Hardcoded - this.client.sendResponse(new NewNavigatorSettingsComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); - 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 InventoryRefreshComposer()); + this.client.sendResponse(new InventoryRefreshComposer());// can we remove this too?? //this.client.sendResponse(new ForumsTestComposer()); this.client.sendResponse(new InventoryAchievementsComposer()); - this.client.sendResponse(new AchievementListComposer(this.client.getHabbo())); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java index 05442efe..6bc2a215 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorDataEvent.java @@ -12,6 +12,5 @@ public class RequestNewNavigatorDataEvent extends MessageHandler { this.client.sendResponse(new NewNavigatorCollapsedCategoriesComposer()); this.client.sendResponse(new NewNavigatorSavedSearchesComposer(this.client.getHabbo().getHabboInfo().getSavedSearches())); this.client.sendResponse(new NewNavigatorEventCategoriesComposer()); - this.client.sendResponse(new NewNavigatorSettingsComposer(this.client.getHabbo().getHabboStats().navigatorWindowSettings)); } } From c63dee00e0ee4947576910cc49f297e9f387912c Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 17:49:52 -0500 Subject: [PATCH 56/94] remove inventory refresh on login --- .../eu/habbo/messages/incoming/handshake/SecureLoginEvent.java | 1 - 1 file changed, 1 deletion(-) 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 dca9c53a..b25292d4 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 @@ -144,7 +144,6 @@ public class SecureLoginEvent extends MessageHandler { this.client.sendResponses(messages); //Hardcoded - this.client.sendResponse(new InventoryRefreshComposer());// can we remove this too?? //this.client.sendResponse(new ForumsTestComposer()); this.client.sendResponse(new InventoryAchievementsComposer()); From 53fb788fd0d65500f069bc56cd850b70d05190ed Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 18:15:39 -0500 Subject: [PATCH 57/94] fix packet name --- .../incoming/handshake/SecureLoginEvent.java | 7 ++----- .../com/eu/habbo/messages/outgoing/Outgoing.java | 2 +- .../mysterybox/MysteryBoxKeysComposer.java} | 6 +++--- .../outgoing/unknown/UnknownComposer5.java | 14 -------------- 4 files changed, 6 insertions(+), 23 deletions(-) rename src/main/java/com/eu/habbo/messages/{incoming/handshake/UnknownComposer5.java => outgoing/mysterybox/MysteryBoxKeysComposer.java} (66%) delete mode 100644 src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java 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 b25292d4..95d772cc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -13,7 +13,6 @@ import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.achievements.AchievementListComposer; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterAccountInfoComposer; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterGameListComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; @@ -24,13 +23,13 @@ import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer; import com.eu.habbo.messages.outgoing.handshake.AvailabilityStatusMessageComposer; import com.eu.habbo.messages.outgoing.handshake.PingComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryAchievementsComposer; -import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; import com.eu.habbo.messages.outgoing.modtool.CfhTopicsMessageComposer; import com.eu.habbo.messages.outgoing.modtool.ModToolComposer; import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer; import com.eu.habbo.messages.outgoing.navigator.*; import com.eu.habbo.messages.outgoing.unknown.BuildersClubExpiredComposer; +import com.eu.habbo.messages.outgoing.mysterybox.MysteryBoxKeysComposer; import com.eu.habbo.messages.outgoing.users.*; import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent; import com.eu.habbo.plugin.events.users.UserLoginEvent; @@ -125,7 +124,7 @@ public class SecureLoginEvent extends MessageHandler { messages.add(new EnableNotificationsComposer(Emulator.getConfig().getBoolean("bubblealerts.enabled", true)).compose()); messages.add(new UserAchievementScoreComposer(this.client.getHabbo()).compose()); messages.add(new IsFirstLoginOfDayComposer(true).compose()); - messages.add(new UnknownComposer5().compose()); + messages.add(new MysteryBoxKeysComposer().compose()); messages.add(new BuildersClubExpiredComposer().compose()); messages.add(new CfhTopicsMessageComposer().compose()); messages.add(new FavoriteRoomsCountComposer(this.client.getHabbo()).compose()); @@ -133,8 +132,6 @@ public class SecureLoginEvent extends MessageHandler { messages.add(new GameCenterAccountInfoComposer(3, 100).compose()); messages.add(new GameCenterAccountInfoComposer(0, 100).compose()); - //messages.add(new MessengerInitComposer(this.client.getHabbo()).compose()); - //messages.add(new FriendsComposer(this.client.getHabbo()).compose()); messages.add(new UserClubComposer(this.client.getHabbo(), SubscriptionHabboClub.HABBO_CLUB, UserClubComposer.RESPONSE_TYPE_LOGIN).compose()); if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java index e38663e7..173ec13f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java @@ -212,7 +212,7 @@ public class Outgoing { //Uknown but work public final static int IsFirstLoginOfDayComposer = 793; // PRODUCTION-201611291003-338511768 //Quest Engine - public final static int UnknownComposer5 = 2833; // PRODUCTION-201611291003-338511768 //Mysterbox + public final static int MysteryBoxKeysComposer = 2833; // PRODUCTION-201611291003-338511768 //Mysterbox public final static int IgnoredUsersComposer = 126; // PRODUCTION-201611291003-338511768 public final static int NewNavigatorMetaDataComposer = 3052; // PRODUCTION-201611291003-338511768 public final static int NewNavigatorSearchResultsComposer = 2690; // PRODUCTION-201611291003-338511768 diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java b/src/main/java/com/eu/habbo/messages/outgoing/mysterybox/MysteryBoxKeysComposer.java similarity index 66% rename from src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java rename to src/main/java/com/eu/habbo/messages/outgoing/mysterybox/MysteryBoxKeysComposer.java index 7cea96ee..8aa8d340 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UnknownComposer5.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/mysterybox/MysteryBoxKeysComposer.java @@ -1,13 +1,13 @@ -package com.eu.habbo.messages.incoming.handshake; +package com.eu.habbo.messages.outgoing.mysterybox; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -public class UnknownComposer5 extends MessageComposer { +public class MysteryBoxKeysComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { - this.response.init(Outgoing.UnknownComposer5); + this.response.init(Outgoing.MysteryBoxKeysComposer); this.response.appendString(""); //Box color this.response.appendString(""); //Key color return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java b/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java deleted file mode 100644 index f9e18d7a..00000000 --- a/src/main/java/com/eu/habbo/messages/outgoing/unknown/UnknownComposer5.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.eu.habbo.messages.outgoing.unknown; - -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.MessageComposer; -import com.eu.habbo.messages.outgoing.Outgoing; - -public class UnknownComposer5 extends MessageComposer { - @Override - protected ServerMessage composeInternal() { - this.response.init(Outgoing.UnknownComposer5); - this.response.appendInt(0); - return this.response; - } -} From 1e32abe426fe66655af131632d19255333d4ebe0 Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 18:30:14 -0500 Subject: [PATCH 58/94] fix homeroom packet --- .../messages/incoming/handshake/SecureLoginEvent.java | 2 +- .../habbo/messages/incoming/rooms/SetHomeRoomEvent.java | 2 +- .../messages/outgoing/users/UserHomeRoomComposer.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) 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 95d772cc..ac1b60b6 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 @@ -114,7 +114,7 @@ public class SecureLoginEvent extends MessageHandler { ArrayList messages = new ArrayList<>(); messages.add(new SecureLoginOKComposer().compose()); - messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose()); + messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose()); messages.add(new UserClothesComposer(this.client.getHabbo()).compose()); messages.add(new NewUserIdentityComposer(habbo).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java index 3f8544e3..7a39e005 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SetHomeRoomEvent.java @@ -10,7 +10,7 @@ public class SetHomeRoomEvent extends MessageHandler { if (roomId != this.client.getHabbo().getHabboInfo().getHomeRoom()) { this.client.getHabbo().getHabboInfo().setHomeRoom(roomId); - this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom())); + this.client.sendResponse(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0)); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java index 5ab9a8c3..4aeae0b3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserHomeRoomComposer.java @@ -6,18 +6,18 @@ import com.eu.habbo.messages.outgoing.Outgoing; public class UserHomeRoomComposer extends MessageComposer { private final int homeRoom; - private final int newRoom; + private final int roomToEnter; - public UserHomeRoomComposer(int homeRoom, int newRoom) { + public UserHomeRoomComposer(int homeRoom, int roomToEnter) { this.homeRoom = homeRoom; - this.newRoom = newRoom; + this.roomToEnter = roomToEnter; } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.UserHomeRoomComposer); this.response.appendInt(this.homeRoom); - this.response.appendInt(this.newRoom); + this.response.appendInt(this.roomToEnter); return this.response; } } From 42ca879d619d16bdcfb08dcda605a0f8ffae0f5d Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 18:42:09 -0500 Subject: [PATCH 59/94] fix retro style option for forwarding --- .../messages/incoming/handshake/SecureLoginEvent.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 ac1b60b6..3e7816d4 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 @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; @@ -114,6 +115,13 @@ public class SecureLoginEvent extends MessageHandler { ArrayList messages = new ArrayList<>(); messages.add(new SecureLoginOKComposer().compose()); + + if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) + messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); + else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) + messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), RoomManager.HOME_ROOM_ID).compose()); + else messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose()); + messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose()); messages.add(new UserClothesComposer(this.client.getHabbo()).compose()); From 929e6a1584662f48a16b753321c1556fbffde421 Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 18 Mar 2022 18:47:47 -0500 Subject: [PATCH 60/94] oops --- .../incoming/handshake/SecureLoginEvent.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 3e7816d4..2a47300f 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 @@ -116,13 +116,14 @@ public class SecureLoginEvent extends MessageHandler { messages.add(new SecureLoginOKComposer().compose()); - if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) - messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); - else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) - messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), RoomManager.HOME_ROOM_ID).compose()); - else messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose()); + int roomIdToEnter = 0; - messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), this.client.getHabbo().getHabboInfo().getHomeRoom()).compose()); + if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && this.client.getHabbo().getHabboInfo().getHomeRoom() != 0) + roomIdToEnter = this.client.getHabbo().getHabboInfo().getHomeRoom(); + else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) + roomIdToEnter = RoomManager.HOME_ROOM_ID; + + messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), roomIdToEnter).compose()); messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose()); messages.add(new UserClothesComposer(this.client.getHabbo()).compose()); messages.add(new NewUserIdentityComposer(habbo).compose()); From 5e9b9c7f30b6f903aafff132bbee4bb9eb4d0fc6 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sat, 19 Mar 2022 17:08:15 +0000 Subject: [PATCH 61/94] Fix issue when try cancel the item on marketplace --- .../eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index 9801eae2..7ac720d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -67,7 +67,7 @@ public class MarketPlace { if (offer != null && habbo.getInventory().getMarketplaceItems().contains(offer)) { RequestOffersEvent.cachedResults.clear(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - try (PreparedStatement ownerCheck = connection.prepareStatement("SELECT user_id FROM marketplace_items WHERE id = ?")) { + try (PreparedStatement ownerCheck = connection.prepareStatement("SELECT user_id FROM marketplace_items WHERE id = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { ownerCheck.setInt(1, offer.getOfferId()); try (ResultSet ownerSet = ownerCheck.executeQuery()) { ownerSet.last(); From 5a66c30e8dc6cea4de1557b4584b93fcb7335646 Mon Sep 17 00:00:00 2001 From: brenoepics Date: Sat, 19 Mar 2022 19:34:21 +0000 Subject: [PATCH 62/94] Feature Friendlist Categories --- sqlupdates/3_0_0 to 3_0_1.sql | 11 +++ .../habbo/habbohotel/messenger/Messenger.java | 10 +-- .../habbohotel/messenger/MessengerBuddy.java | 6 +- .../messenger/MessengerCategory.java | 31 +++++++ .../eu/habbo/habbohotel/users/HabboInfo.java | 55 ++++++++++++ .../incoming/friends/ChangeRelationEvent.java | 2 +- .../outgoing/friends/FriendsComposer.java | 6 +- .../friends/MessengerInitComposer.java | 19 +++- .../friends/UpdateFriendComposer.java | 88 +++++++++++-------- 9 files changed, 177 insertions(+), 51 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 71ab3129..8ae563e1 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -10,3 +10,14 @@ INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1'); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('youtube.apikey', ''); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.gifts.length.max', '300'); + +-- Add friendship categories table +CREATE TABLE `messenger_categories` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(25) NOT NULL, + `user_id` int NOT NULL, + UNIQUE KEY `identifier` (`id`) +); + +-- Set an ID (int) from category list items +ALTER TABLE messenger_friendships ADD category int NOT NULL DEFAULT '0' AFTER friends_since; \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java index b1d3eb25..fa4603cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -302,7 +302,7 @@ public class Messenger { buddy.setLook(owner.getHabboInfo().getLook()); buddy.setGender(owner.getHabboInfo().getGender()); buddy.setUsername(owner.getHabboInfo().getUsername()); - habbo.getClient().sendResponse(new UpdateFriendComposer(buddy)); + habbo.getClient().sendResponse(new UpdateFriendComposer(habbo, buddy, 0)); } } } @@ -368,12 +368,12 @@ public class Messenger { return; } - habboTo.getClient().sendResponse(new UpdateFriendComposer(to)); - habboFrom.getClient().sendResponse(new UpdateFriendComposer(from)); + habboTo.getClient().sendResponse(new UpdateFriendComposer(habboTo, to, 1)); + habboFrom.getClient().sendResponse(new UpdateFriendComposer(habboFrom, from, 1)); } else if (habboTo != null) { - habboTo.getClient().sendResponse(new UpdateFriendComposer(this.loadFriend(habboTo, userFrom))); + habboTo.getClient().sendResponse(new UpdateFriendComposer(habboTo, this.loadFriend(habboTo, userFrom), 1)); } else if (habboFrom != null) { - habboFrom.getClient().sendResponse(new UpdateFriendComposer(this.loadFriend(habboFrom, userTo))); + habboFrom.getClient().sendResponse(new UpdateFriendComposer(habboFrom, this.loadFriend(habboFrom, userTo), 1)); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index e68eefb5..d879d004 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -25,6 +25,7 @@ public class MessengerBuddy implements Runnable, ISerialize { private String look = ""; private String motto = ""; private short relation; + private int categoryId = 0; private boolean inRoom; private int userOne = 0; @@ -37,6 +38,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.motto = set.getString("motto"); this.look = set.getString("look"); this.relation = (short) set.getInt("relation"); + this.categoryId = set.getInt("category"); this.userOne = set.getInt("user_one_id"); this.inRoom = false; if (this.online == 1) { @@ -136,6 +138,8 @@ public class MessengerBuddy implements Runnable, ISerialize { Emulator.getThreading().run(this); } + public int getCategoryId() { return this.categoryId; } + public boolean inRoom() { return this.inRoom; } @@ -181,7 +185,7 @@ public class MessengerBuddy implements Runnable, ISerialize { message.appendBoolean(this.online == 1); message.appendBoolean(this.inRoom); //IN ROOM message.appendString(this.look); - message.appendInt(0); // Friends category ID + message.appendInt(this.categoryId); // Friends category ID message.appendString(this.motto); message.appendString(""); //Last seen as DATETIMESTRING message.appendString(""); // Realname or Facebookame as String diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java new file mode 100644 index 00000000..b19a43b0 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerCategory.java @@ -0,0 +1,31 @@ +package com.eu.habbo.habbohotel.messenger; + +public class MessengerCategory { + private int user_id; + private String name; + private int id; + + public MessengerCategory(String name, int user_id, int id) { + this.name = name; + this.user_id = user_id; + this.id = id; + } + + public String getName() { + return name; + } + + public int getUserId() { + return user_id; + } + + public int getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + public void setId(int id) { this.id = id; } +} + diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index a7fd28a5..8c166631 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GamePlayer; +import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Rank; import com.eu.habbo.habbohotel.pets.PetTasks; @@ -55,6 +56,7 @@ public class HabboInfo implements Runnable { private int webPublishTimestamp; private String machineID; private List savedSearches = new ArrayList<>(); + private List messengerCategories = new ArrayList<>(); public HabboInfo(ResultSet set) { try { @@ -88,6 +90,7 @@ public class HabboInfo implements Runnable { this.loadCurrencies(); this.loadSavedSearches(); + this.loadMessengerCategories(); } private void loadCurrencies() { @@ -179,6 +182,56 @@ public class HabboInfo implements Runnable { } } + private void loadMessengerCategories() { + this.messengerCategories = new ArrayList<>(); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM messenger_categories WHERE user_id = ?")) { + statement.setInt(1, this.id); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.messengerCategories.add(new MessengerCategory(set.getString("name"), set.getInt("user_id"), set.getInt("id"))); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + } + + public void addMessengerCategory(MessengerCategory category) { + this.messengerCategories.add(category); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO messenger_categories (name, user_id) VALUES (?, ?)", Statement.RETURN_GENERATED_KEYS)) { + statement.setString(1, category.getName()); + statement.setInt(2, this.id); + int affectedRows = statement.executeUpdate(); + + if (affectedRows == 0) { + throw new SQLException("Creating messenger category failed, no rows affected."); + } + + try (ResultSet generatedKeys = statement.getGeneratedKeys()) { + if (generatedKeys.next()) { + category.setId(generatedKeys.getInt(1)); + } else { + throw new SQLException("Creating messenger category failed, no ID found."); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + } + + public void deleteMessengerCategory(MessengerCategory category) { + this.messengerCategories.remove(category); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_categories WHERE id = ?")) { + statement.setInt(1, category.getId()); + statement.execute(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + } + public int getCurrencyAmount(int type) { return this.currencies.get(type); } @@ -478,6 +531,8 @@ public class HabboInfo implements Runnable { return this.savedSearches; } + public List getMessengerCategories() { return this.messengerCategories; } + @Override public void run() { this.saveCurrencies(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java index cb02842f..d2790194 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/ChangeRelationEvent.java @@ -16,7 +16,7 @@ public class ChangeRelationEvent extends MessageHandler { UserRelationShipEvent event = new UserRelationShipEvent(this.client.getHabbo(), buddy, relationId); if (!event.isCancelled()) { buddy.setRelation(event.relationShip); - this.client.sendResponse(new UpdateFriendComposer(buddy)); + this.client.sendResponse(new UpdateFriendComposer(this.client.getHabbo(), buddy, 0)); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java index 2fd69a9a..287e87cb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java @@ -41,10 +41,10 @@ public class FriendsComposer extends MessageComposer { this.response.appendBoolean(row.getOnline() == 1); this.response.appendBoolean(row.inRoom()); //IN ROOM this.response.appendString(row.getOnline() == 1 ? row.getLook() : ""); - this.response.appendInt(0); + this.response.appendInt(row.getCategoryId()); //Friends category this.response.appendString(row.getMotto()); - this.response.appendString(""); - this.response.appendString(""); + this.response.appendString(""); //Last seen as DATETIMESTRING + this.response.appendString(""); //Realname or Facebookame as String this.response.appendBoolean(false); //Offline messaging. this.response.appendBoolean(false); this.response.appendBoolean(false); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java index a48e6e65..de3b9206 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/MessengerInitComposer.java @@ -1,11 +1,15 @@ package com.eu.habbo.messages.outgoing.friends; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; +import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import java.util.List; + public class MessengerInitComposer extends MessageComposer { private final Habbo habbo; @@ -15,6 +19,7 @@ public class MessengerInitComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { + this.response.init(Outgoing.MessengerInitComposer); if (this.habbo.hasPermission("acc_infinite_friends")) { this.response.appendInt(Integer.MAX_VALUE); @@ -25,9 +30,19 @@ public class MessengerInitComposer extends MessageComposer { this.response.appendInt(1337); this.response.appendInt(Messenger.MAXIMUM_FRIENDS_HC); } + if (!this.habbo.getHabboInfo().getMessengerCategories().isEmpty()) { - //this.response.appendInt(1000); - this.response.appendInt(0); + List messengerCategories = this.habbo.getHabboInfo().getMessengerCategories(); + this.response.appendInt(messengerCategories.size()); + + for (MessengerCategory mc : messengerCategories) { + this.response.appendInt(mc.getId()); + this.response.appendString(mc.getName()); + } + } else { + this.response.appendInt(0); + } return this.response; } } + diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java index 907fa9a0..1be0b1ac 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UpdateFriendComposer.java @@ -1,6 +1,11 @@ package com.eu.habbo.messages.outgoing.friends; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + import com.eu.habbo.habbohotel.messenger.MessengerBuddy; +import com.eu.habbo.habbohotel.messenger.MessengerCategory; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.ServerMessage; @@ -8,60 +13,65 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; public class UpdateFriendComposer extends MessageComposer { - private MessengerBuddy buddy; + private Collection buddies; private Habbo habbo; + private int action; - public UpdateFriendComposer(MessengerBuddy buddy) { - this.buddy = buddy; + public UpdateFriendComposer(Habbo habbo, MessengerBuddy buddy, Integer action) { + this.habbo = habbo; + this.buddies = Collections.singletonList(buddy); + this.action = action; } - - public UpdateFriendComposer(Habbo habbo) { + public UpdateFriendComposer(Habbo habbo, Collection buddies, Integer action) { this.habbo = habbo; + this.buddies = buddies; + this.action = action; } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.UpdateFriendComposer); - if (this.buddy != null) { - this.response.appendInt(0); - this.response.appendInt(1); - this.response.appendInt(0); - this.response.appendInt(this.buddy.getId()); - this.response.appendString(this.buddy.getUsername()); - this.response.appendInt(this.buddy.getGender().equals(HabboGender.M) ? 0 : 1); - this.response.appendBoolean(this.buddy.getOnline() == 1); - this.response.appendBoolean(this.buddy.inRoom()); //In room - this.response.appendString(this.buddy.getLook()); - this.response.appendInt(0); - this.response.appendString(this.buddy.getMotto()); - this.response.appendString(""); - this.response.appendString(""); - this.response.appendBoolean(false); - this.response.appendBoolean(false); - this.response.appendBoolean(false); - this.response.appendShort(this.buddy.getRelation()); + if (this.habbo != null && !this.habbo.getHabboInfo().getMessengerCategories().isEmpty()) { + + List messengerCategories = this.habbo.getHabboInfo().getMessengerCategories(); + this.response.appendInt(messengerCategories.size()); + + for (MessengerCategory mc : messengerCategories) { + this.response.appendInt(mc.getId()); + this.response.appendString(mc.getName()); + } } else { this.response.appendInt(0); - this.response.appendInt(1); - this.response.appendInt(0); - this.response.appendInt(-1); - this.response.appendString("Staff Chat"); - this.response.appendInt(0); - this.response.appendBoolean(true); - this.response.appendBoolean(false); //In room - this.response.appendString(this.habbo.getHabboInfo().getLook()); - this.response.appendInt(0); - this.response.appendString(""); - this.response.appendString(""); - this.response.appendString(""); - this.response.appendBoolean(false); - this.response.appendBoolean(false); - this.response.appendBoolean(false); - this.response.appendShort(0); } + + this.response.appendInt(buddies.size()); // totalbuddies + + for(MessengerBuddy buddy : buddies){ + + if (buddy != null) { + this.response.appendInt(this.action); // -1 = removed friendId / 0 = updated friend / 1 = added friend + this.response.appendInt(buddy.getId()); + if (this.action == -1) { + continue; + } + this.response.appendString(buddy.getUsername()); + this.response.appendInt(buddy.getGender().equals(HabboGender.M) ? 0 : 1); + this.response.appendBoolean(buddy.getOnline() == 1); + this.response.appendBoolean(buddy.inRoom()); //In room + this.response.appendString(buddy.getLook()); + this.response.appendInt(buddy.getCategoryId()); + this.response.appendString(buddy.getMotto()); + this.response.appendString(""); //Last seen as DATETIMESTRING + this.response.appendString(""); //Realname or Facebookame as String + this.response.appendBoolean(false); //Offline messaging. + this.response.appendBoolean(false); + this.response.appendBoolean(false); + this.response.appendShort(buddy.getRelation()); + } + } return this.response; } } From 84aa16b50ec50437bad03a0088f8b95db9f4e3be Mon Sep 17 00:00:00 2001 From: xjoao Date: Sat, 19 Mar 2022 19:37:16 +0000 Subject: [PATCH 63/94] Loop Fix --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java index ba845ba4..294d2749 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -56,6 +56,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { if (i == this.bubble.getType()) { this.bubble = RoomChatMessageBubbles.NORMAL; + break; } } } From 1ea080f89ab5bcea3fdc2638f8d2372a7f2b74a0 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sat, 19 Mar 2022 19:44:16 +0000 Subject: [PATCH 64/94] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 877e6bfb..1f0a1c0f 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,8 @@ If we ever are to make paid features or plugins, we will not prevent or discoura - Thijmen - Brenoepic - Stankman + - Laynester + From 2cf32fb1312689cb8cb2b09d5e38a23816b5ff49 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Sun, 20 Mar 2022 00:14:23 -0300 Subject: [PATCH 65/94] Feature: InteractionBuildArea --- .../habbo/habbohotel/items/ItemManager.java | 1 + .../interactions/InteractionBuildArea.java | 253 ++++++++++++++++++ .../interactions/InteractionCustomValues.java | 2 +- .../interactions/InteractionMuteArea.java | 5 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 8 + .../rooms/items/AdvertisingSaveEvent.java | 6 +- .../rooms/items/RoomPlaceItemEvent.java | 55 ++-- 7 files changed, 299 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index f702d68c..e62b1f0a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -161,6 +161,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("viking_cotie", InteractionVikingCotie.class)); this.interactionsList.add(new ItemInteraction("tile_fxprovider_nfs", InteractionTileEffectProvider.class)); this.interactionsList.add(new ItemInteraction("mutearea", InteractionMuteArea.class)); + this.interactionsList.add(new ItemInteraction("buildarea", InteractionBuildArea.class)); this.interactionsList.add(new ItemInteraction("information_terminal", InteractionInformationTerminal.class)); this.interactionsList.add(new ItemInteraction("external_image", InteractionExternalImage.class)); this.interactionsList.add(new ItemInteraction("youtube", InteractionYoutubeTV.class)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java new file mode 100644 index 00000000..015ab451 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java @@ -0,0 +1,253 @@ +package com.eu.habbo.habbohotel.items.interactions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomTileState; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.HabboManager; +import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; +import com.eu.habbo.messages.outgoing.rooms.items.RoomFloorItemsComposer; +import gnu.trove.TCollections; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.hash.THashMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.set.hash.THashSet; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; + +public class InteractionBuildArea extends InteractionCustomValues { + public static THashMap defaultValues = new THashMap() { + { + this.put("tilesLeft", "0"); + } + + { + this.put("tilesRight", "0"); + } + + { + this.put("tilesFront", "0"); + } + + { + this.put("tilesBack", "0"); + } + + { + this.put("builders", ""); + } + }; + + private THashSet tiles; + + public InteractionBuildArea(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem, defaultValues); + tiles = new THashSet<>(); + } + + public InteractionBuildArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues); + tiles = new THashSet<>(); + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + this.regenAffectedTiles(room); + } + + @Override + public void onPickUp(Room room) { + super.onPickUp(room); + + ArrayList builderNames = new ArrayList<>(Arrays.asList(this.values.get("builders").split(";"))); + THashSet canBuild = new THashSet<>(); + + for (String builderName : builderNames) { + Habbo builder = Emulator.getGameEnvironment().getHabboManager().getHabbo(builderName); + HabboInfo builderInfo; + if (builder != null) { + builderInfo = builder.getHabboInfo(); + } else { + builderInfo = HabboManager.getOfflineHabboInfo(builderName); + } + if (builderInfo != null) { + canBuild.add(builderInfo.getId()); + } + } + + if (!canBuild.isEmpty()) { + for (RoomTile tile : this.tiles) { + THashSet tileItems = room.getItemsAt(tile); + for (HabboItem tileItem : tileItems) { + if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { + room.pickUpItem(tileItem, null); + } + } + } + } + + this.tiles.clear(); + } + + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + super.onMove(room, oldLocation, newLocation); + + ArrayList builderNames = new ArrayList<>(Arrays.asList(this.values.get("builders").split(";"))); + THashSet canBuild = new THashSet<>(); + + for (String builderName : builderNames) { + Habbo builder = Emulator.getGameEnvironment().getHabboManager().getHabbo(builderName); + HabboInfo builderInfo; + if (builder != null) { + builderInfo = builder.getHabboInfo(); + } else { + builderInfo = HabboManager.getOfflineHabboInfo(builderName); + } + if (builderInfo != null) { + canBuild.add(builderInfo.getId()); + } + } + + THashSet oldTiles = this.tiles; + THashSet newTiles = new THashSet<>(); + + int minX = Math.max(0, newLocation.x - Integer.parseInt(this.values.get("tilesBack"))); + int minY = Math.max(0, newLocation.y - Integer.parseInt(this.values.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), newLocation.x + Integer.parseInt(this.values.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), newLocation.y + Integer.parseInt(this.values.get("tilesLeft"))); + + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + RoomTile tile = room.getLayout().getTile((short) x, (short) y); + if (tile != null && tile.state != RoomTileState.INVALID) + newTiles.add(tile); + } + } + + if (!canBuild.isEmpty()) { + for (RoomTile tile : oldTiles) { + THashSet tileItems = room.getItemsAt(tile); + if(newTiles.contains(tile)) continue; + for (HabboItem tileItem : tileItems) { + if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { + room.pickUpItem(tileItem, null); + } + } + } + } + this.regenAffectedTiles(room); + } + + public boolean inSquare(RoomTile location) { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + + if (room != null && this.tiles.size() == 0) { + regenAffectedTiles(room); + } + + return this.tiles.contains(location); + + } + + private void regenAffectedTiles(Room room) { + int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack"))); + int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft"))); + + this.tiles.clear(); + + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + RoomTile tile = room.getLayout().getTile((short) x, (short) y); + if (tile != null && tile.state != RoomTileState.INVALID) + this.tiles.add(tile); + } + } + } + + @Override + public void onCustomValuesSaved(Room room, GameClient client, THashMap oldValues) { + regenAffectedTiles(room); + ArrayList builderNames = new ArrayList<>(Arrays.asList(this.values.get("builders").split(";"))); + THashSet canBuild = new THashSet<>(); + + for (String builderName : builderNames) { + Habbo builder = Emulator.getGameEnvironment().getHabboManager().getHabbo(builderName); + HabboInfo builderInfo; + if (builder != null) { + builderInfo = builder.getHabboInfo(); + } else { + builderInfo = HabboManager.getOfflineHabboInfo(builderName); + } + if (builderInfo != null) { + canBuild.add(builderInfo.getId()); + } + } + + THashSet oldTiles = new THashSet<>(); + + int minX = Math.max(0, this.getX() - Integer.parseInt(oldValues.get("tilesBack"))); + int minY = Math.max(0, this.getY() - Integer.parseInt(oldValues.get("tilesRight"))); + int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(oldValues.get("tilesFront"))); + int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(oldValues.get("tilesLeft"))); + + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + RoomTile tile = room.getLayout().getTile((short) x, (short) y); + if (tile != null && tile.state != RoomTileState.INVALID && !this.tiles.contains(tile)) + oldTiles.add(tile); + } + } + if (!canBuild.isEmpty()) { + for (RoomTile tile : oldTiles) { + THashSet tileItems = room.getItemsAt(tile); + for (HabboItem tileItem : tileItems) { + if (canBuild.contains(tileItem.getUserId()) && tileItem != this) { + room.pickUpItem(tileItem, null); + } + } + } + } + + // show the effect + Item effectItem = Emulator.getGameEnvironment().getItemManager().getItem("mutearea_sign2"); + + if(effectItem != null) { + TIntObjectMap ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); + ownerNames.put(-1, "System"); + THashSet items = new THashSet<>(); + + int id = 0; + for(RoomTile tile : this.tiles) { + id--; + HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0); + item.setX(tile.x); + item.setY(tile.y); + item.setZ(tile.relativeHeight()); + items.add(item); + } + + client.sendResponse(new RoomFloorItemsComposer(ownerNames, items)); + Emulator.getThreading().run(() -> { + for(HabboItem item : items) { + client.sendResponse(new RemoveFloorItemComposer(item, true)); + } + }, 3000); + } + } + + public boolean isBuilder(String Username){ + return Arrays.asList(this.values.get("builders").split(";")).contains(Username); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java index 9ef005bc..5a275c28 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java @@ -80,7 +80,7 @@ public abstract class InteractionCustomValues extends HabboItem { super.serializeExtradata(serverMessage); } - public void onCustomValuesSaved(Room room, GameClient client) { + public void onCustomValuesSaved(Room room, GameClient client, THashMap oldValues) { } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java index 29a7c0ac..beed1131 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java @@ -17,7 +17,6 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; -import java.awt.*; import java.sql.ResultSet; import java.sql.SQLException; @@ -125,8 +124,8 @@ public class InteractionMuteArea extends InteractionCustomValues { } @Override - public void onCustomValuesSaved(Room room, GameClient client) { - super.onCustomValuesSaved(room, client); + public void onCustomValuesSaved(Room room, GameClient client, THashMap oldValues) { + super.onCustomValuesSaved(room, client, oldValues); this.regenAffectedTiles(room); 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 af82a1ae..09c54558 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2407,6 +2407,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionMuteArea) { this.roomSpecialTypes.addUndefined(item); + } else if (item instanceof InteractionBuildArea) { + this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionTagPole) { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionTagField) { @@ -4487,6 +4489,12 @@ public class Room implements Comparable, ISerialize, Runnable { } } + for (HabboItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { + if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) { + return FurnitureMovementError.NONE; + } + } + return FurnitureMovementError.NO_RIGHTS; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java index d705f8ff..b25f3792 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/AdvertisingSaveEvent.java @@ -6,6 +6,9 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionRoomAds; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; +import gnu.trove.map.hash.THashMap; + +import java.util.Map; public class AdvertisingSaveEvent extends MessageHandler { @Override @@ -26,6 +29,7 @@ public class AdvertisingSaveEvent extends MessageHandler { return; } if (item instanceof InteractionCustomValues) { + THashMap oldValues = new THashMap<>(((InteractionCustomValues) item).values); int count = this.packet.readInt(); for (int i = 0; i < count / 2; i++) { String key = this.packet.readString(); @@ -42,7 +46,7 @@ public class AdvertisingSaveEvent extends MessageHandler { item.needsUpdate(true); Emulator.getThreading().run(item); room.updateItem(item); - ((InteractionCustomValues) item).onCustomValuesSaved(room, this.client); + ((InteractionCustomValues) item).onCustomValuesSaved(room, this.client, oldValues); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java index 8cdeb7d0..0f293184 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java @@ -3,10 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.modtool.ScripterManager; -import com.eu.habbo.habbohotel.rooms.FurnitureMovementError; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; @@ -20,7 +17,7 @@ public class RoomPlaceItemEvent extends MessageHandler { int itemId = -1; - if (values.length != 0) itemId = Integer.valueOf(values[0]); + if (values.length != 0) itemId = Integer.parseInt(values[0]); if (!this.client.getHabbo().getRoomUnit().isInRoom()) { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); @@ -56,27 +53,9 @@ public class RoomPlaceItemEvent extends MessageHandler { } if (item.getBaseItem().getType() == FurnitureType.FLOOR) { - short x = Short.valueOf(values[1]); - short y = Short.valueOf(values[2]); - int rotation = Integer.valueOf(values[3]); - if (rentSpace != null && !room.hasRights(this.client.getHabbo())) { - if (item instanceof InteractionRoller || - item instanceof InteractionStackHelper || - item instanceof InteractionWired || - item instanceof InteractionBackgroundToner || - item instanceof InteractionRoomAds || - item instanceof InteractionCannon || - item instanceof InteractionPuzzleBox || - item.getBaseItem().getType() == FurnitureType.WALL) { - this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); - return; - } - - if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(x, y, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { - this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); - return; - } - } + short x = Short.parseShort(values[1]); + short y = Short.parseShort(values[2]); + int rotation = Integer.parseInt(values[3]); RoomTile tile = room.getLayout().getTile(x, y); @@ -88,6 +67,30 @@ public class RoomPlaceItemEvent extends MessageHandler { return; } + HabboItem buildArea = null; + for (HabboItem area : room.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) { + if (((InteractionBuildArea) area).inSquare(tile)) { + buildArea = area; + } + } + + if ((rentSpace != null || buildArea != null) && !room.hasRights(this.client.getHabbo())) { + if (item instanceof InteractionRoller || + item instanceof InteractionStackHelper || + item instanceof InteractionWired || + item instanceof InteractionBackgroundToner || + item instanceof InteractionRoomAds || + item instanceof InteractionCannon || + item instanceof InteractionPuzzleBox || + item.getBaseItem().getType() == FurnitureType.WALL) { + this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + return; + } + if (rentSpace != null && !RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(x, y, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) { + this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); + return; + } + } FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation); if (!error.equals(FurnitureMovementError.NONE)) { From e7bde3cbee9f4674997a192a91a4e3009cbdd90e Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sun, 20 Mar 2022 20:34:44 +0000 Subject: [PATCH 66/94] Fixed RoomDataComposer to send correct room score --- .../com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java index 7dea5e9f..895cacc6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomDataComposer.java @@ -39,8 +39,8 @@ public class RoomDataComposer extends MessageComposer { this.response.appendInt(this.room.getUsersMax()); this.response.appendString(this.room.getDescription()); this.response.appendInt(this.room.getTradeMode()); - this.response.appendInt(2); this.response.appendInt(this.room.getScore()); + this.response.appendInt(2);//Top rated room rank this.response.appendInt(this.room.getCategory()); if (!this.room.getTags().isEmpty()) { From 5b24a732975a4be3438c0fcec7efa43dfe85f441 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Mon, 21 Mar 2022 12:30:42 +0000 Subject: [PATCH 67/94] Fix NPE --- src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 1cb10037..14a7915e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -374,7 +374,7 @@ public class WiredHandler { } } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as row_count, wired_rewards_given.* FROM wired_rewards_given WHERE user_id = ? AND wired_item = ? ORDER BY timestamp DESC LIMIT ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as row_count, wired_rewards_given.* FROM wired_rewards_given WHERE user_id = ? AND wired_item = ? ORDER BY timestamp DESC LIMIT ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(2, wiredBox.getId()); statement.setInt(3, wiredBox.rewardItems.size()); From 66397c8d98436035df1207c55845ad1e5394f2c6 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 21 Mar 2022 12:31:05 -0400 Subject: [PATCH 68/94] Fix the busted inventory fragments --- .../commands/EmptyInventoryCommand.java | 1 - .../inventory/RequestInventoryItemsEvent.java | 17 ++++++++++------- .../inventory/InventoryItemsComposer.java | 14 +++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java index 779dd3e5..a7a205a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java @@ -42,7 +42,6 @@ public class EmptyInventoryCommand extends Command { Emulator.getThreading().run(new QueryDeleteHabboItems(items)); habbo.getClient().sendResponse(new InventoryRefreshComposer()); - habbo.getClient().sendResponse(new InventoryItemsComposer(0, 1, gameClient.getHabbo().getInventory().getItemsComponent().getItems())); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT); } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java index 2b9641cb..f5047b72 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java @@ -17,20 +17,23 @@ public class RequestInventoryItemsEvent extends MessageHandler { @Override public void handle() throws Exception { int totalItems = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); - int pages = (int) Math.ceil((double) totalItems / 1000.0); + int totalFragments = (int) Math.ceil((double) totalItems / 1000.0); - if (pages == 0) { - pages = 1; + if (totalFragments == 0) { + totalFragments = 1; } synchronized (this.client.getHabbo().getInventory().getItemsComponent().getItems()) { TIntObjectMap items = new TIntObjectHashMap<>(); TIntObjectIterator iterator = this.client.getHabbo().getInventory().getItemsComponent().getItems().iterator(); + int count = 0; - int page = 0; + int fragmentNumber = 0; + for (int i = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); i-- > 0; ) { + if (count == 0) { - page++; + fragmentNumber++; } try { @@ -43,13 +46,13 @@ public class RequestInventoryItemsEvent extends MessageHandler { } if (count == 1000) { - this.client.sendResponse(new InventoryItemsComposer(page, pages, items)); + this.client.sendResponse(new InventoryItemsComposer(fragmentNumber, totalFragments, items)); count = 0; items.clear(); } } - this.client.sendResponse(new InventoryItemsComposer(page, pages, items)); + if(count > 0 && items.size() > 0) this.client.sendResponse(new InventoryItemsComposer(fragmentNumber, totalFragments, items)); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java index 258ce1a9..a8a24ed0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java @@ -14,13 +14,13 @@ import org.slf4j.LoggerFactory; public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure { private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class); - private final int page; - private final int out; + private final int fragmentNumber; + private final int totalFragments; private final TIntObjectMap items; - public InventoryItemsComposer(int page, int out, TIntObjectMap items) { - this.page = page; - this.out = out; + public InventoryItemsComposer(int fragmentNumber, int totalFragments, TIntObjectMap items) { + this.fragmentNumber = fragmentNumber; + this.totalFragments = totalFragments; this.items = items; } @@ -28,8 +28,8 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec protected ServerMessage composeInternal() { try { this.response.init(Outgoing.InventoryItemsComposer); - this.response.appendInt(this.out); - this.response.appendInt(this.page - 1); + this.response.appendInt(this.totalFragments); + this.response.appendInt(this.fragmentNumber - 1); this.response.appendInt(this.items.size()); this.items.forEachEntry(this); From 797b887a9892c0881edeb7ddfa8865be33b04466 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Mon, 21 Mar 2022 18:37:24 +0000 Subject: [PATCH 69/94] Fix --- src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java | 3 +++ .../eu/habbo/habbohotel/users/inventory/BadgesComponent.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java index 5903cdc5..18176593 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -57,6 +57,9 @@ public class HabboBadge implements Runnable { public void run() { try { if (this.needsInsert) { + if (this.habbo.getInventory().getBadgesComponent().hasBadge(this.code)) + return; + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, slot_id, badge_code) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, this.habbo.getHabboInfo().getId()); statement.setInt(2, this.slot); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java index 02573ff4..845ba2cb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java @@ -160,7 +160,8 @@ public class BadgesComponent { public void addBadge(HabboBadge badge) { synchronized (this.badges) { - this.badges.add(badge); + if (!this.hasBadge(badge.getCode())) + this.badges.add(badge); } } From dfd12bd56aa08bfb08c8306e15eb66d2f4f687c6 Mon Sep 17 00:00:00 2001 From: brenoepics Date: Mon, 21 Mar 2022 18:51:52 +0000 Subject: [PATCH 70/94] New campaign calendar system --- sqlupdates/3_0_0 to 3_0_1.sql | 54 +++++- .../eu/habbo/habbohotel/GameEnvironment.java | 6 + .../campaign/calendar/CalendarCampaign.java | 64 ++++++++ .../campaign/calendar/CalendarManager.java | 154 ++++++++++++++++++ .../calendar/CalendarRewardClaimed.java | 50 ++++++ .../calendar}/CalendarRewardObject.java | 45 ++++- .../habbohotel/catalog/CatalogManager.java | 43 +---- .../habbohotel/commands/CalendarCommand.java | 20 ++- .../habbohotel/commands/CommandHandler.java | 1 + .../commands/UpdateCalendarCommand.java | 21 +++ .../eu/habbo/habbohotel/users/HabboStats.java | 7 +- .../AdventCalendarForceOpenEvent.java | 4 +- .../calendar/AdventCalendarOpenDayEvent.java | 4 +- .../incoming/handshake/UsernameEvent.java | 18 +- .../calendar/AdventCalendarDataComposer.java | 22 ++- .../AdventCalendarProductComposer.java | 32 +++- .../users/calendar/UserClaimRewardEvent.java | 23 +++ 17 files changed, 498 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java rename src/main/java/com/eu/habbo/habbohotel/{catalog => campaign/calendar}/CalendarRewardObject.java (59%) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java create mode 100644 src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 8ae563e1..7fc77aed 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -20,4 +20,56 @@ CREATE TABLE `messenger_categories` ( ); -- Set an ID (int) from category list items -ALTER TABLE messenger_friendships ADD category int NOT NULL DEFAULT '0' AFTER friends_since; \ No newline at end of file +ALTER TABLE messenger_friendships ADD category int NOT NULL DEFAULT '0' AFTER friends_since; + +-- ---------------------------- +-- Table structure for calendar_campaigns +-- ---------------------------- +DROP TABLE IF EXISTS `calendar_campaigns`; +CREATE TABLE `calendar_campaigns` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', + `start_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `total_days` int NOT NULL DEFAULT '30', + `lock_expired` enum('1','0') NOT NULL DEFAULT '1', + `enabled` enum('1','0') NOT NULL DEFAULT '1', + UNIQUE KEY `id` (`id`) +); + +-- ---------------------------- +-- Records of calendar_campaigns +-- ---------------------------- +INSERT INTO `calendar_campaigns` VALUES ('1', 'test', '', '2022-02-09 16:49:13', '31', '1', '1'); + +-- ---------------------------- +-- Table structure for calendar_rewards +-- ---------------------------- +DROP TABLE IF EXISTS `calendar_rewards`; +CREATE TABLE `calendar_rewards` ( + `id` int NOT NULL AUTO_INCREMENT, + `campaign_id` int NOT NULL DEFAULT '0', + `product_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `credits` int NOT NULL DEFAULT '0', + `pixels` int NOT NULL DEFAULT '0', + `points` int NOT NULL DEFAULT '0', + `points_type` int NOT NULL DEFAULT '0', + `badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `item_id` int NOT NULL DEFAULT '0', + `subscription_type` enum('HABBO_CLUB') CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL, + `subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '', + `subscription_days` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) USING BTREE +); + +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.default', 'test'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.pixels.hc_modifier', '2.0'); + +-- Calendar force open +ALTER TABLE `permissions` ADD COLUMN `acc_calendar_force` enum('0','1') NULL DEFAULT '0'; + +-- UpdateCalendar command. +ALTER TABLE `permissions` ADD `cmd_update_calendar` ENUM('0', '1') NOT NULL DEFAULT '0'; +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_update_calendar', ':update_calendar'), ('commands.keys.cmd_update_calendar', 'update_calendar'); +INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.success.cmd_update_calendar', 'Calendar updated successfully!'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index a614cb05..7944ae8c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.*; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.BotManager; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.commands.CommandHandler; import com.eu.habbo.habbohotel.crafting.CraftingManager; @@ -54,6 +55,7 @@ public class GameEnvironment { private CraftingManager craftingManager; private PollManager pollManager; private SubscriptionManager subscriptionManager; + private CalendarManager calendarManager; public void load() throws Exception { LOGGER.info("GameEnvironment -> Loading..."); @@ -78,6 +80,7 @@ public class GameEnvironment { this.wordFilter = new WordFilter(); this.craftingManager = new CraftingManager(); this.pollManager = new PollManager(); + this.calendarManager = new CalendarManager(); this.roomManager.loadPublicRooms(); this.navigatorManager.loadNavigator(); @@ -114,6 +117,7 @@ public class GameEnvironment { this.itemManager.dispose(); this.hotelViewManager.dispose(); this.subscriptionManager.dispose(); + this.calendarManager.dispose(); LOGGER.info("GameEnvironment -> Disposed!"); } @@ -206,4 +210,6 @@ public class GameEnvironment { public SubscriptionManager getSubscriptionManager() { return this.subscriptionManager; } + + public CalendarManager getCalendarManager() { return this.calendarManager; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java new file mode 100644 index 00000000..b00cf7fc --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java @@ -0,0 +1,64 @@ +package com.eu.habbo.habbohotel.campaign.calendar; + +import gnu.trove.map.hash.THashMap; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Map; + +public class CalendarCampaign { + private int id; + private final String name; + private final String image; + private Map rewards = new THashMap<>(); + private final Timestamp start_timestamp; + private final int total_days; + private final boolean lock_expired; + + public CalendarCampaign(ResultSet set) throws SQLException { + this.id = set.getInt("id"); + this.name = set.getString("name"); + this.image = set.getString("image"); + this.start_timestamp = set.getTimestamp("start_timestamp"); + this.total_days = set.getInt("total_days"); + this.lock_expired = set.getInt("lock_expired") == 1; + } + + public CalendarCampaign(int id, String name, String image, Timestamp start_timestamp, int total_days, boolean lock_expired) { + this.id = id; + this.name = name; + this.image = image; + this.start_timestamp = start_timestamp; + this.total_days = total_days; + this.lock_expired = lock_expired; + } + + public int getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public String getImage() { + return this.image; + } + + public Timestamp getStartTimestamp() { + return this.start_timestamp; + } + + public int getTotalDays() { return this.total_days; } + + public boolean getLockExpired() { return this.lock_expired; } + + public Map getRewards() { return rewards; } + + public void setId(int id) { this.id = id; } + + public void setRewards(Map rewards) { this.rewards = rewards; } + + public void addReward(CalendarRewardObject reward) { this.rewards.put(reward.getId(), reward); } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java new file mode 100644 index 00000000..4e2720e8 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java @@ -0,0 +1,154 @@ +package com.eu.habbo.habbohotel.campaign.calendar; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer; +import com.eu.habbo.plugin.events.users.calendar.UserClaimRewardEvent; +import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.*; +import java.util.*; +import java.util.Date; + +import static java.time.temporal.ChronoUnit.DAYS; + + +public class CalendarManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CalendarCampaign.class); + + final private static Map calendarCampaigns = new THashMap<>(); + public static double HC_MODIFIER; + + public CalendarManager() { + long millis = System.currentTimeMillis(); + this.reload(); + LOGGER.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis)); + } + + public void dispose(){ + calendarCampaigns.clear(); + } + + public boolean reload() { + this.dispose(); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_campaigns WHERE enabled = 1")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + calendarCampaigns.put(set.getInt("id"), new CalendarCampaign(set)); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + return false; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + CalendarCampaign campaign = calendarCampaigns.get(set.getInt("campaign_id")); + if(campaign != null){ + campaign.addReward(new CalendarRewardObject(set)); + } + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + return false; + } + + HC_MODIFIER = Emulator.getConfig().getDouble("hotel.calendar.pixels.hc_modifier", 2.0); + + return true; + } + + public void addCampaign(CalendarCampaign campaign) { + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_campaigns ( name, image, start_timestamp, total_days, lock_expired) VALUES (?, ?, ?, ? , ?)", Statement.RETURN_GENERATED_KEYS)) { + statement.setString(1, campaign.getName()); + statement.setString(2, campaign.getImage()); + statement.setTimestamp(3, campaign.getStartTimestamp()); + statement.setInt(4, campaign.getTotalDays()); + statement.setBoolean(5, campaign.getLockExpired()); + int affectedRows = statement.executeUpdate(); + + if (affectedRows == 0) { + throw new SQLException("Creating calendar campaign failed, no rows affected."); + } + + try (ResultSet generatedKeys = statement.getGeneratedKeys()) { + if (generatedKeys.next()) { + campaign.setId(generatedKeys.getInt(1)); + } else { + throw new SQLException("Creating calendar campaign failed, no ID found."); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + + calendarCampaigns.put(campaign.getId(), campaign); + } + + public boolean deleteCampaign(CalendarCampaign campaign) { + calendarCampaigns.remove(campaign.getId()); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM calendar_campaigns WHERE id = ? LIMIT 1")) { + statement.setInt(1, campaign.getId()); + return statement.execute(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + + return false; + } + + public CalendarCampaign getCalendarCampaign(String campaignName) { + return calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null); + } + public Map getCalendarCampaigns() { + return calendarCampaigns; + } + + public void claimCalendarReward(Habbo habbo, String campaignName, int day, boolean force) { + CalendarCampaign campaign = calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null); + if(campaign == null) return; + if (habbo.getHabboStats().calendarRewardsClaimed.stream().noneMatch(claimed -> claimed.getCampaignId() == campaign.getId() && claimed.getDay() == day)) { + + Set keys = campaign.getRewards().keySet(); + Map rewards = new THashMap<>(); + if(keys.isEmpty()) return; + keys.forEach(key -> rewards.put(rewards.size() + 1, key)); + int rand = Emulator.getRandom().nextInt(rewards.size() - 1 + 1) + 1; + int random = rewards.get(rand); + CalendarRewardObject object = campaign.getRewards().get(random); + if (object == null) return; + int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + if(daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) { + int diff = (daysBetween - day); + if ((((diff <= 2 || !campaign.getLockExpired()) && diff >= 0) || (force && habbo.hasPermission("acc_calendar_force")))) { + + if (Emulator.getPluginManager().fireEvent(new UserClaimRewardEvent(habbo, campaign, day, object, force)).isCancelled()) { + return; + } + + habbo.getHabboStats().calendarRewardsClaimed.add(new CalendarRewardClaimed(habbo.getHabboInfo().getId(), campaign.getId(), day, object.getId(), new Timestamp(System.currentTimeMillis()))); + habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object, habbo)); + object.give(habbo); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, campaign_id, day, reward_id, timestamp) VALUES (?, ?, ?, ?, ?)")) { + statement.setInt(1, habbo.getHabboInfo().getId()); + statement.setInt(2, campaign.getId()); + statement.setInt(3, day); + statement.setInt(4, object.getId()); + statement.setTimestamp(5, new Timestamp(System.currentTimeMillis())); + statement.execute(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } + } + } + } + } +} + diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java new file mode 100644 index 00000000..3cc0c56d --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java @@ -0,0 +1,50 @@ +package com.eu.habbo.habbohotel.campaign.calendar; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; + +public class CalendarRewardClaimed { + private final int user_id; + private final int campaign; + private final int day; + private final int reward_id; + private final Timestamp timestamp; + + public CalendarRewardClaimed(ResultSet set) throws SQLException { + this.user_id = set.getInt("user_id"); + this.campaign = set.getInt("campaign_id"); + this.day = set.getInt("day"); + this.reward_id = set.getInt("reward_id"); + this.timestamp = set.getTimestamp("timestamp"); + } + + public CalendarRewardClaimed(int user_id, int campaign, int day, int reward_id, Timestamp timestamp) { + this.user_id = user_id; + this.campaign = campaign; + this.day = day; + this.reward_id = reward_id; + this.timestamp = timestamp; + } + + public int getUserId() { + return this.user_id; + } + + public int getCampaignId() { + return this.campaign; + } + + public int getDay() { + return this.day; + } + + public int getRewardId() { + return this.reward_id; + } + + public Timestamp getTimestamp() { + return this.timestamp; + } + +} diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardObject.java similarity index 59% rename from src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java rename to src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardObject.java index f2b135b5..efe8f91d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardObject.java @@ -1,32 +1,47 @@ -package com.eu.habbo.habbohotel.catalog; +package com.eu.habbo.habbohotel.campaign.calendar; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.subscriptions.Subscription; +import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class CalendarRewardObject { + private static final Logger LOGGER = LoggerFactory.getLogger(CalendarRewardObject.class); + private final int id; + private final String productName; private final String customImage; private final int credits; + private final int pixels; private final int points; private final int pointsType; private final String badge; private final int itemId; + private final String subscription_type; + private final int subscription_days; public CalendarRewardObject(ResultSet set) throws SQLException { this.id = set.getInt("id"); + this.productName = set.getString("product_name"); this.customImage = set.getString("custom_image"); this.credits = set.getInt("credits"); + this.pixels = set.getInt("pixels"); this.points = set.getInt("points"); this.pointsType = set.getInt("points_type"); this.badge = set.getString("badge"); this.itemId = set.getInt("item_id"); + this.subscription_type = set.getString("subscription_type"); + this.subscription_days = set.getInt("subscription_days"); } public void give(Habbo habbo) { @@ -34,6 +49,10 @@ public class CalendarRewardObject { habbo.giveCredits(this.credits); } + if (this.pixels > 0) { + habbo.givePixels((int)(this.pixels * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0))); + } + if (this.points > 0) { habbo.givePoints(this.pointsType, this.points); } @@ -42,6 +61,14 @@ public class CalendarRewardObject { habbo.addBadge(this.badge); } + if(this.subscription_type != null && !this.subscription_type.isEmpty()) { + if ("HABBO_CLUB".equals(this.subscription_type)) { + habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, this.subscription_days * 86400); + } else { + habbo.getHabboStats().createSubscription(this.subscription_type, this.subscription_days * 86400); + } + } + if (this.itemId > 0) { Item item = getItem(); @@ -71,6 +98,9 @@ public class CalendarRewardObject { return this.credits; } + public int getPixels() { + return this.pixels; + } public int getPoints() { return this.points; } @@ -79,6 +109,18 @@ public class CalendarRewardObject { return this.pointsType; } + public String getProductName() { + return productName; + } + + public String getSubscriptionType() { + return subscription_type; + } + + public int getSubscriptionDays() { + return subscription_days; + } + public String getBadge() { return this.badge; } @@ -86,4 +128,5 @@ public class CalendarRewardObject { public Item getItem() { return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId); } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index 6eb01a77..3e543e0c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject; import com.eu.habbo.habbohotel.catalog.layouts.*; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.guilds.Guild; @@ -190,7 +191,6 @@ public class CatalogManager { public final TIntIntHashMap offerDefs; public final Item ecotronItem; public final THashMap limitedNumbers; - public final THashMap calendarRewards; private final List vouchers; public CatalogManager() { @@ -207,7 +207,6 @@ public class CatalogManager { this.offerDefs = new TIntIntHashMap(); this.vouchers = new ArrayList<>(); this.limitedNumbers = new THashMap<>(); - this.calendarRewards = new THashMap<>(); this.initialize(); @@ -230,7 +229,6 @@ public class CatalogManager { this.loadClothing(); this.loadRecycler(); this.loadGiftWrappers(); - this.loadCalendarRewards(); } private synchronized void loadLimitedNumbers() { @@ -482,23 +480,6 @@ public class CatalogManager { } } - private void loadCalendarRewards() { - synchronized (this.calendarRewards) { - this.calendarRewards.clear(); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) { - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - this.calendarRewards.put(set.getInt("id"), new CalendarRewardObject(set)); - } - } - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - } - } - } - - private void loadClothing() { synchronized (this.clothing) { this.clothing.clear(); @@ -1167,28 +1148,6 @@ public class CatalogManager { return offers; } - public void claimCalendarReward(Habbo habbo, int day, boolean force) { - if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) { - CalendarRewardObject object = this.calendarRewards.get((day+1)); - int actualDay = (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400); - int diff = (actualDay - day); - if (((diff <= 2 && diff >= 0) || force) && object != null) { - habbo.getHabboStats().calendarRewardsClaimed.add(day); - habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object)); - object.give(habbo); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) { - statement.setInt(1, habbo.getHabboInfo().getId()); - statement.setInt(2, day); - statement.setInt(3, Emulator.getIntUnixTimestamp()); - statement.execute(); - } catch (SQLException e) { - LOGGER.error("Caught SQL exception", e); - } - } - } - } - public TargetOffer getTargetOffer(int offerId) { return this.targetOffers.get(offerId); } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java index 5d996740..ea9d3c69 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java @@ -1,10 +1,17 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer; import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; +import java.sql.Timestamp; +import java.time.Duration; +import java.util.Date; + +import static java.time.temporal.ChronoUnit.DAYS; + public class CalendarCommand extends Command { public CalendarCommand() { super("cmd_calendar", Emulator.getTexts().getValue("commands.keys.cmd_calendar").split(";")); @@ -13,8 +20,17 @@ public class CalendarCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { - gameClient.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, true)); - gameClient.sendResponse(new NuxAlertComposer("openView/calendar")); + String campaignName = Emulator.getConfig().getValue("hotel.calendar.default"); + + if(params.length > 1 && gameClient.getHabbo().hasPermission("cmd_calendar_staff")) { + campaignName = params[1]; + } + CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName); + if(campaign == null) return false; + int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + if(daysBetween >= 0) { + gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); + } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java index a37d9482..64dd09d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -275,6 +275,7 @@ public class CommandHandler { addCommand(new UnmuteCommand()); addCommand(new UpdateAchievements()); addCommand(new UpdateBotsCommand()); + addCommand(new UpdateCalendarCommand()); addCommand(new UpdateCatalogCommand()); addCommand(new UpdateConfigCommand()); addCommand(new UpdateGuildPartsCommand()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java new file mode 100644 index 00000000..a110c20b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateCalendarCommand.java @@ -0,0 +1,21 @@ +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.messages.outgoing.catalog.*; +import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; + +public class UpdateCalendarCommand extends Command { + + public UpdateCalendarCommand() { + super("cmd_update_calendar", Emulator.getTexts().getValue("commands.keys.cmd_update_calendar").split(";")); + } + + @Override + public boolean handle(GameClient gameClient, String[] params) { + Emulator.getGameEnvironment().getCalendarManager().reload(); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.cmd_update_calendar"), RoomChatMessageBubbles.ALERT); + return true; + } +} 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 75808977..462af849 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardClaimed; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.achievements.AchievementManager; @@ -33,7 +34,7 @@ public class HabboStats implements Runnable { public final TIntArrayList secretRecipes; public final HabboNavigatorWindowSettings navigatorWindowSettings; public final THashMap cache; - public final TIntArrayList calendarRewardsClaimed; + public final ArrayList calendarRewardsClaimed; public final TIntObjectMap offerCache = new TIntObjectHashMap<>(); private final AtomicInteger lastOnlineTime = new AtomicInteger(Emulator.getIntUnixTimestamp()); private final THashMap achievementProgress; @@ -109,7 +110,7 @@ public class HabboStats implements Runnable { this.ignoredUsers = new TIntArrayList(0); this.roomsVists = new TIntArrayList(0); this.secretRecipes = new TIntArrayList(0); - this.calendarRewardsClaimed = new TIntArrayList(0); + this.calendarRewardsClaimed = new ArrayList<>(); this.habboInfo = habboInfo; @@ -206,7 +207,7 @@ public class HabboStats implements Runnable { calendarRewardsStatement.setInt(1, this.habboInfo.getId()); try (ResultSet rewardSet = calendarRewardsStatement.executeQuery()) { while (rewardSet.next()) { - this.calendarRewardsClaimed.add(rewardSet.getInt("reward_id")); + this.calendarRewardsClaimed.add(new CalendarRewardClaimed(rewardSet)); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java index 1ab77c2c..bca8c1de 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java @@ -6,9 +6,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class AdventCalendarForceOpenEvent extends MessageHandler { @Override public void handle() throws Exception { - String campaign = this.packet.readString(); + String campaignName = this.packet.readString(); int day = this.packet.readInt(); - Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, true); + Emulator.getGameEnvironment().getCalendarManager().claimCalendarReward(this.client.getHabbo(), campaignName, day, true); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java index 9c68cfd0..58970271 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java @@ -6,9 +6,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; public class AdventCalendarOpenDayEvent extends MessageHandler { @Override public void handle() throws Exception { - String campaign = this.packet.readString(); + String campaignName = this.packet.readString(); int day = this.packet.readInt(); - Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, false); + Emulator.getGameEnvironment().getCalendarManager().claimCalendarReward(this.client.getHabbo(), campaignName, day, false); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java index aa4d946f..3636c6c0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign; import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer; @@ -11,9 +12,14 @@ import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.Timestamp; +import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Date; +import java.util.concurrent.TimeUnit; + +import static java.time.temporal.ChronoUnit.DAYS; public class UsernameEvent extends MessageHandler { @Override @@ -24,7 +30,7 @@ public class UsernameEvent extends MessageHandler { calendar = true; } else { - long daysBetween = ChronoUnit.DAYS.between(new Date((long) this.client.getHabbo().getHabboInfo().getLastOnline() * 1000L).toInstant(), new Date().toInstant()); + long daysBetween = DAYS.between(new Date((long) this.client.getHabbo().getHabboInfo().getLastOnline() * 1000L).toInstant(), new Date().toInstant()); Date lastLogin = new Date(this.client.getHabbo().getHabboInfo().getLastOnline()); @@ -84,8 +90,14 @@ public class UsernameEvent extends MessageHandler { } if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { - this.client.sendResponse(new AdventCalendarDataComposer("xmas15", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true)); - this.client.sendResponse(new NuxAlertComposer("openView/calendar")); + CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(Emulator.getConfig().getValue("hotel.calendar.default")); + if(campaign != null){ + long daysBetween = DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + if(daysBetween >= 0) { + this.client.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); + this.client.sendResponse(new NuxAlertComposer("openView/calendar")); + } + }; } if (TargetOffer.ACTIVE_TARGET_OFFER_ID > 0) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java index 82c512f2..abf20a7a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java @@ -1,20 +1,24 @@ package com.eu.habbo.messages.outgoing.events.calendar; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardClaimed; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.list.array.TIntArrayList; -import gnu.trove.procedure.TIntProcedure; + +import java.util.ArrayList; public class AdventCalendarDataComposer extends MessageComposer { private final String eventName; + private final String campaignImage; private final int totalDays; private final int currentDay; - private final TIntArrayList unlocked; + private final ArrayList unlocked; private final boolean lockExpired; - public AdventCalendarDataComposer(String eventName, int totalDays, int currentDay, TIntArrayList unlocked, boolean lockExpired) { + public AdventCalendarDataComposer(String eventName, String campaignImage, int totalDays, int currentDay, ArrayList unlocked, boolean lockExpired) { this.eventName = eventName; + this.campaignImage = campaignImage; this.totalDays = totalDays; this.currentDay = currentDay; this.unlocked = unlocked; @@ -25,23 +29,23 @@ public class AdventCalendarDataComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.AdventCalendarDataComposer); this.response.appendString(this.eventName); - this.response.appendString(""); + this.response.appendString(this.campaignImage); this.response.appendInt(this.currentDay); this.response.appendInt(this.totalDays); this.response.appendInt(this.unlocked.size()); TIntArrayList expired = new TIntArrayList(); - for (int i = 0; i < this.totalDays; i++) { + if (this.lockExpired) { for (int i = 0; i < this.totalDays; i++) { expired.add(i); } + } expired.remove(this.currentDay); if(this.currentDay > 1) expired.remove(this.currentDay - 2); if(this.currentDay > 0) expired.remove(this.currentDay - 1); - this.unlocked.forEach(value -> { - AdventCalendarDataComposer.this.response.appendInt(value); - expired.remove(value); - return true; + this.unlocked.forEach(claimed -> { + AdventCalendarDataComposer.this.response.appendInt(claimed.getDay()); + expired.remove(claimed.getDay()); }); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java index 999eefbb..fb23b318 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java @@ -1,7 +1,9 @@ package com.eu.habbo.messages.outgoing.events.calendar; -import com.eu.habbo.habbohotel.catalog.CalendarRewardObject; -import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -9,19 +11,39 @@ import com.eu.habbo.messages.outgoing.Outgoing; public class AdventCalendarProductComposer extends MessageComposer { public final boolean visible; public final CalendarRewardObject rewardObject; + public final Habbo habbo; - public AdventCalendarProductComposer(boolean visible, CalendarRewardObject rewardObject) { + public AdventCalendarProductComposer(boolean visible, CalendarRewardObject rewardObject, Habbo habbo) { this.visible = visible; this.rewardObject = rewardObject; + this.habbo = habbo; } @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.AdventCalendarProductComposer); this.response.appendBoolean(this.visible); - this.response.appendString(this.rewardObject.getItem().getName()); + + String className = ""; + String productName = this.rewardObject.getProductName() + .replace("%credits%", String.valueOf(this.rewardObject.getCredits())) + .replace("%pixels%", String.valueOf((int) (this.rewardObject.getPixels() * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0)))) + .replace("%points%", String.valueOf(this.rewardObject.getPoints())) + .replace("%points_type%", String.valueOf(this.rewardObject.getPointsType())) + .replace("%badge%", this.rewardObject.getBadge()); + if(this.rewardObject.getSubscriptionType() != null){ + productName = productName.replace("%subscription_type%", this.rewardObject.getSubscriptionType()).replace("%subscription_days%", String.valueOf(this.rewardObject.getSubscriptionDays())); + } + + if(this.rewardObject.getItem() != null){ + productName = productName.replace("%item%", this.rewardObject.getItem().getName()); + className = this.rewardObject.getItem().getName(); + } + + this.response.appendString(productName); this.response.appendString(this.rewardObject.getCustomImage()); - this.response.appendString(this.rewardObject.getItem().getName()); + this.response.appendString(className); + return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java new file mode 100644 index 00000000..c57f60db --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/users/calendar/UserClaimRewardEvent.java @@ -0,0 +1,23 @@ +package com.eu.habbo.plugin.events.users.calendar; + +import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign; +import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.plugin.events.users.UserEvent; + +public class UserClaimRewardEvent extends UserEvent { + + public CalendarCampaign campaign; + public int day; + public CalendarRewardObject reward; + public boolean force; + + public UserClaimRewardEvent(Habbo habbo, CalendarCampaign campaign, int day, CalendarRewardObject reward, boolean force) { + super(habbo); + + this.campaign = campaign; + this.day = day; + this.reward = reward; + this.force = force; + } +} From 287af8aba48aa0c92d4bd9d59c5c67d79b87f47a Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Mon, 21 Mar 2022 19:16:31 -0300 Subject: [PATCH 71/94] Fix calendar timestamp --- sqlupdates/3_0_0 to 3_0_1.sql | 62 ++++++++++--------- .../campaign/calendar/CalendarCampaign.java | 8 +-- .../campaign/calendar/CalendarManager.java | 6 +- .../habbohotel/commands/CalendarCommand.java | 2 +- .../incoming/handshake/UsernameEvent.java | 3 +- 5 files changed, 43 insertions(+), 38 deletions(-) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index f82618c9..42ace602 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -11,45 +11,51 @@ INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('youtube.apikey', ''); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.gifts.length.max', '300'); - -- ---------------------------- +-- ---------------------------- -- Table structure for calendar_campaigns -- ---------------------------- DROP TABLE IF EXISTS `calendar_campaigns`; CREATE TABLE `calendar_campaigns` ( - `id` int NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL DEFAULT '', - `image` varchar(255) NOT NULL DEFAULT '', - `start_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', - `total_days` int NOT NULL DEFAULT '30', - `lock_expired` enum('1','0') NOT NULL DEFAULT '1', - `enabled` enum('1','0') NOT NULL DEFAULT '1', - UNIQUE KEY `id` (`id`) + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', + `start_timestamp` int NOT NULL DEFAULT '0', + `total_days` int NOT NULL DEFAULT '30', + `lock_expired` enum('1','0') NOT NULL DEFAULT '1', + `enabled` enum('1','0') NOT NULL DEFAULT '1', + UNIQUE KEY `id` (`id`) ); --- ---------------------------- --- Records of calendar_campaigns --- ---------------------------- -INSERT INTO `calendar_campaigns` VALUES ('1', 'test', '', '2022-02-09 16:49:13', '31', '1', '1'); - -- ---------------------------- -- Table structure for calendar_rewards -- ---------------------------- DROP TABLE IF EXISTS `calendar_rewards`; CREATE TABLE `calendar_rewards` ( - `id` int NOT NULL AUTO_INCREMENT, - `campaign_id` int NOT NULL DEFAULT '0', - `product_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', - `custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', - `credits` int NOT NULL DEFAULT '0', - `pixels` int NOT NULL DEFAULT '0', - `points` int NOT NULL DEFAULT '0', - `points_type` int NOT NULL DEFAULT '0', - `badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', - `item_id` int NOT NULL DEFAULT '0', - `subscription_type` enum('HABBO_CLUB') CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL, - `subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '', - `subscription_days` int NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) USING BTREE + `id` int NOT NULL AUTO_INCREMENT, + `campaign_id` int NOT NULL DEFAULT '0', + `product_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `credits` int NOT NULL DEFAULT '0', + `pixels` int NOT NULL DEFAULT '0', + `points` int NOT NULL DEFAULT '0', + `points_type` int NOT NULL DEFAULT '0', + `badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '', + `item_id` int NOT NULL DEFAULT '0', + `subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '', + `subscription_days` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) USING BTREE +); + +-- ---------------------------- +-- Table structure for calendar_rewards_claimed +-- ---------------------------- +DROP TABLE IF EXISTS `calendar_rewards_claimed`; +CREATE TABLE `calendar_rewards_claimed` ( + `user_id` int NOT NULL, + `campaign_id` int NOT NULL DEFAULT '0', + `day` int NOT NULL, + `reward_id` int NOT NULL, + `timestamp` int NOT NULL ); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.default', 'test'); diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java index b00cf7fc..29733ddb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarCampaign.java @@ -12,7 +12,7 @@ public class CalendarCampaign { private final String name; private final String image; private Map rewards = new THashMap<>(); - private final Timestamp start_timestamp; + private final Integer start_timestamp; private final int total_days; private final boolean lock_expired; @@ -20,12 +20,12 @@ public class CalendarCampaign { this.id = set.getInt("id"); this.name = set.getString("name"); this.image = set.getString("image"); - this.start_timestamp = set.getTimestamp("start_timestamp"); + this.start_timestamp = set.getInt("start_timestamp"); this.total_days = set.getInt("total_days"); this.lock_expired = set.getInt("lock_expired") == 1; } - public CalendarCampaign(int id, String name, String image, Timestamp start_timestamp, int total_days, boolean lock_expired) { + public CalendarCampaign(int id, String name, String image, Integer start_timestamp, int total_days, boolean lock_expired) { this.id = id; this.name = name; this.image = image; @@ -46,7 +46,7 @@ public class CalendarCampaign { return this.image; } - public Timestamp getStartTimestamp() { + public Integer getStartTimestamp() { return this.start_timestamp; } diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java index 4e2720e8..1336f88f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java @@ -68,7 +68,7 @@ public class CalendarManager { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_campaigns ( name, image, start_timestamp, total_days, lock_expired) VALUES (?, ?, ?, ? , ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setString(1, campaign.getName()); statement.setString(2, campaign.getImage()); - statement.setTimestamp(3, campaign.getStartTimestamp()); + statement.setInt(3, campaign.getStartTimestamp()); statement.setInt(4, campaign.getTotalDays()); statement.setBoolean(5, campaign.getLockExpired()); int affectedRows = statement.executeUpdate(); @@ -124,7 +124,7 @@ public class CalendarManager { int random = rewards.get(rand); CalendarRewardObject object = campaign.getRewards().get(random); if (object == null) return; - int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant()); if(daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) { int diff = (daysBetween - day); if ((((diff <= 2 || !campaign.getLockExpired()) && diff >= 0) || (force && habbo.hasPermission("acc_calendar_force")))) { @@ -141,7 +141,7 @@ public class CalendarManager { statement.setInt(2, campaign.getId()); statement.setInt(3, day); statement.setInt(4, object.getId()); - statement.setTimestamp(5, new Timestamp(System.currentTimeMillis())); + statement.setInt(5, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { LOGGER.error("Caught SQL exception", e); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java index ea9d3c69..dd2a773f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java @@ -27,7 +27,7 @@ public class CalendarCommand extends Command { } CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName); if(campaign == null) return false; - int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant()); if(daysBetween >= 0) { gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java index 3636c6c0..c217e946 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java @@ -88,11 +88,10 @@ public class UsernameEvent extends MessageHandler { deleteStatement.execute(); } } - if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(Emulator.getConfig().getValue("hotel.calendar.default")); if(campaign != null){ - long daysBetween = DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant()); + long daysBetween = DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant()); if(daysBetween >= 0) { this.client.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired())); this.client.sendResponse(new NuxAlertComposer("openView/calendar")); From dbd40c195ba1709938ff1b66ad46b75dee794875 Mon Sep 17 00:00:00 2001 From: dank074 Date: Mon, 21 Mar 2022 21:30:09 -0500 Subject: [PATCH 72/94] refactor wired save packet handling --- .../items/interactions/InteractionWired.java | 33 ++++++++++ .../InteractionWiredCondition.java | 4 +- .../interactions/InteractionWiredEffect.java | 4 +- .../interactions/InteractionWiredTrigger.java | 3 +- .../interactions/wired/WiredSettings.java | 63 +++++++++++++++++++ .../WiredConditionDateRangeActive.java | 11 ++-- .../WiredConditionFurniHaveFurni.java | 14 ++--- .../WiredConditionFurniHaveHabbo.java | 11 ++-- .../WiredConditionFurniTypeMatch.java | 10 ++- .../conditions/WiredConditionGroupMember.java | 3 +- .../conditions/WiredConditionHabboCount.java | 10 +-- .../WiredConditionHabboHasEffect.java | 8 +-- .../WiredConditionHabboHasHandItem.java | 8 +-- .../WiredConditionHabboWearsBadge.java | 7 +-- .../WiredConditionLessTimeElapsed.java | 9 ++- .../WiredConditionMatchStatePosition.java | 19 +++--- .../WiredConditionMoreTimeElapsed.java | 9 ++- .../WiredConditionNotFurniHaveFurni.java | 14 ++--- .../WiredConditionNotFurniHaveHabbo.java | 11 ++-- .../WiredConditionNotFurniTypeMatch.java | 10 ++- .../WiredConditionNotHabboCount.java | 10 +-- .../WiredConditionNotHabboHasEffect.java | 8 +-- .../WiredConditionNotHabboWearsBadge.java | 7 +-- .../conditions/WiredConditionNotInGroup.java | 3 +- .../conditions/WiredConditionNotInTeam.java | 8 +-- .../conditions/WiredConditionTeamMember.java | 8 +-- .../WiredConditionTriggerOnFurni.java | 10 ++- .../wired/effects/WiredEffectBotClothes.java | 11 ++-- .../effects/WiredEffectBotFollowHabbo.java | 15 ++--- .../effects/WiredEffectBotGiveHandItem.java | 14 ++--- .../wired/effects/WiredEffectBotTalk.java | 14 ++--- .../effects/WiredEffectBotTalkToHabbo.java | 14 ++--- .../wired/effects/WiredEffectBotTeleport.java | 12 ++-- .../effects/WiredEffectBotWalkToFurni.java | 12 ++-- .../WiredEffectChangeFurniDirection.java | 18 +++--- ...redEffectGiveHotelviewBonusRarePoints.java | 10 ++- .../WiredEffectGiveHotelviewHofPoints.java | 11 ++-- .../wired/effects/WiredEffectGiveRespect.java | 10 ++- .../wired/effects/WiredEffectGiveReward.java | 19 +++--- .../wired/effects/WiredEffectGiveScore.java | 14 ++--- .../effects/WiredEffectGiveScoreToTeam.java | 16 +++-- .../wired/effects/WiredEffectJoinTeam.java | 12 ++-- .../wired/effects/WiredEffectKickHabbo.java | 9 ++- .../wired/effects/WiredEffectLeaveTeam.java | 8 +-- .../wired/effects/WiredEffectMatchFurni.java | 20 +++--- .../effects/WiredEffectMoveFurniAway.java | 11 ++-- .../wired/effects/WiredEffectMoveFurniTo.java | 18 +++--- .../effects/WiredEffectMoveFurniTowards.java | 12 ++-- .../effects/WiredEffectMoveRotateFurni.java | 18 +++--- .../wired/effects/WiredEffectMuteHabbo.java | 15 +++-- .../wired/effects/WiredEffectResetTimers.java | 10 +-- .../wired/effects/WiredEffectTeleport.java | 12 ++-- .../wired/effects/WiredEffectToggleFurni.java | 12 ++-- .../effects/WiredEffectToggleRandom.java | 12 ++-- .../effects/WiredEffectTriggerStacks.java | 12 ++-- .../wired/effects/WiredEffectWhisper.java | 13 ++-- .../wired/triggers/WiredTriggerAtSetTime.java | 7 ++- .../triggers/WiredTriggerAtTimeLong.java | 8 +-- .../triggers/WiredTriggerBotReachedFurni.java | 11 ++-- .../triggers/WiredTriggerBotReachedHabbo.java | 7 +-- .../wired/triggers/WiredTriggerCollision.java | 3 +- .../WiredTriggerFurniStateToggled.java | 10 ++- .../wired/triggers/WiredTriggerGameEnds.java | 3 +- .../triggers/WiredTriggerGameStarts.java | 3 +- .../triggers/WiredTriggerHabboEntersRoom.java | 6 +- .../WiredTriggerHabboSaysKeyword.java | 9 +-- .../WiredTriggerHabboWalkOffFurni.java | 10 ++- .../WiredTriggerHabboWalkOnFurni.java | 10 ++- .../wired/triggers/WiredTriggerRepeater.java | 8 +-- .../triggers/WiredTriggerRepeaterLong.java | 8 +-- .../triggers/WiredTriggerScoreAchieved.java | 7 ++- .../wired/WiredConditionSaveDataEvent.java | 9 ++- .../wired/WiredEffectSaveDataEvent.java | 6 +- .../wired/WiredTriggerSaveDataEvent.java | 9 ++- 74 files changed, 444 insertions(+), 389 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 8a8f1e7f..166768cb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer; import gnu.trove.map.hash.TLongLongHashMap; @@ -126,4 +128,35 @@ public abstract class InteractionWired extends InteractionDefault { public void addUserExecutionCache(int roomUnitId, long timestamp) { this.userExecutionCache.put((long)roomUnitId, timestamp); } + + public static WiredSettings readSettings(ClientMessage packet, boolean isEffect) + { + int intParamCount = packet.readInt(); + int[] intParams = new int[intParamCount]; + + for(int i = 0; i < intParamCount; i++) + { + intParams[i] = packet.readInt(); + } + + String stringParam = packet.readString(); + + int itemCount = packet.readInt(); + int[] itemIds = new int[itemCount]; + + for(int i = 0; i < itemCount; i++) + { + itemIds[i] = packet.readInt(); + } + + WiredSettings settings = new WiredSettings(intParams, stringParam, itemIds, -1); + + if(isEffect) + { + settings.setDelay(packet.readInt()); + } + + settings.setStuffTypeSelectionCode(packet.readInt()); + return settings; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java index 7bf21fe1..ef63491f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java @@ -2,11 +2,11 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; import java.sql.ResultSet; @@ -43,7 +43,7 @@ public abstract class InteractionWiredCondition extends InteractionWired { public abstract WiredConditionType getType(); - public abstract boolean saveData(ClientMessage packet); + public abstract boolean saveData(WiredSettings settings); public WiredConditionOperator operator() { return WiredConditionOperator.AND; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index 59da2b6f..e58e3659 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -2,10 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; @@ -43,7 +43,7 @@ public abstract class InteractionWiredEffect extends InteractionWired { } } - public abstract boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException; + public abstract boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException; public int getDelay() { return this.delay; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index c0bbaabb..91fb8c08 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -44,7 +45,7 @@ public abstract class InteractionWiredTrigger extends InteractionWired { public abstract WiredTriggerType getType(); - public abstract boolean saveData(ClientMessage packet); + public abstract boolean saveData(WiredSettings settings); protected int getDelay() { return this.delay; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java new file mode 100644 index 00000000..b6027a06 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java @@ -0,0 +1,63 @@ +package com.eu.habbo.habbohotel.items.interactions.wired; + +public class WiredSettings { + private int[] intParams; + private String stringParam; + private int[] furniIds; + private int stuffTypeSelectionCode; + private int delay; + + public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode, int delay) + { + this.furniIds = furniIds; + this.intParams = intParams; + this.stringParam = stringParam; + this.stuffTypeSelectionCode = stuffTypeSelectionCode; + this.delay = delay; + } + + public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode) + { + this(intParams, stringParam, furniIds, stuffTypeSelectionCode, 0); + } + + public int getStuffTypeSelectionCode() { + return stuffTypeSelectionCode; + } + + public void setStuffTypeSelectionCode(int stuffTypeSelectionCode) { + this.stuffTypeSelectionCode = stuffTypeSelectionCode; + } + + public int[] getFurniIds() { + return furniIds; + } + + public void setFurniIds(int[] furniIds) { + this.furniIds = furniIds; + } + + public String getStringParam() { + return stringParam; + } + + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + public int[] getIntParams() { + return intParams; + } + + public void setIntParams(int[] intParams) { + this.intParams = intParams; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int delay) { + this.delay = delay; + } +} 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 d4b92964..11f1276f 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 @@ -3,12 +3,13 @@ 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.WiredSettings; 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 com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; @@ -50,10 +51,10 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.startDate = packet.readInt(); - this.endDate = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 2) return false; + this.startDate = settings.getIntParams()[0]; + this.endDate = settings.getIntParams()[1]; return true; } 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 ddce19a5..22ec093a 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -136,15 +137,12 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - int count; - packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; - this.all = packet.readInt() == 1; + this.all = settings.getIntParams()[0] == 1; - packet.readString(); - - count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -153,7 +151,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java index a0d07087..d26e3db5 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -136,13 +137,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - int count; - packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; - packet.readString(); - - count = packet.readInt(); if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -151,7 +148,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java index 47c42d64..9330457c 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -117,11 +118,8 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -130,7 +128,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java index cc01ba75..5d4133d2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -69,7 +70,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index d5e93e21..df8e2108 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -86,11 +87,10 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.lowerLimit = packet.readInt(); - this.upperLimit = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 2) return false; + this.lowerLimit = settings.getIntParams()[0]; + this.upperLimit = settings.getIntParams()[1]; return true; } 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 7e1580f0..5f9f5b1a 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -76,10 +77,9 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.effectId = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.effectId = settings.getIntParams()[0]; return true; } 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 0d351e98..d60ddede 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -51,10 +52,9 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.handItem = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.handItem = settings.getIntParams()[0]; return true; } 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 b4f0df9f..8d2b3dbe 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -88,10 +89,8 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.badge = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.badge = settings.getStringParam(); return true; } 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 b40ee5e7..f4db5bba 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -81,11 +82,9 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.cycles = packet.readInt(); - + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.cycles = settings.getIntParams()[0]; return true; } 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 76ece81c..cd185dab 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.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -69,28 +70,24 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) { - int count; - packet.readInt(); - - this.state = packet.readInt() == 1; - this.direction = packet.readInt() == 1; - this.position = packet.readInt() == 1; - - packet.readString(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 3) return false; + this.state = settings.getIntParams()[0] == 1; + this.direction = settings.getIntParams()[1] == 1; + this.position = settings.getIntParams()[2] == 1; Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) return true; - count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.settings.clear(); for (int i = 0; i < count; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem item = room.getHabboItem(itemId); if (item != null) 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 0be6ba15..83bd3004 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -81,11 +82,9 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.cycles = packet.readInt(); - + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.cycles = settings.getIntParams()[0]; return true; } 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 279f61bd..b09314c8 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -137,14 +138,11 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.all = settings.getIntParams()[0] == 1; - this.all = packet.readInt() == 1; - - packet.readString(); - - int count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -153,7 +151,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); 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 87f3bc9a..c046fde1 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -136,12 +137,8 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -150,7 +147,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java index 30c9ea51..595eee3e 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -117,11 +118,8 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -130,7 +128,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } } 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 3075c4ff..7f1d6cab 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -85,11 +86,10 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.lowerLimit = packet.readInt(); - this.upperLimit = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 2) return false; + this.lowerLimit = settings.getIntParams()[0]; + this.upperLimit = settings.getIntParams()[1]; return true; } 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 ae1c20bb..3f1a733d 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -76,10 +77,9 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.effectId = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.effectId = settings.getIntParams()[0]; return true; } 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 6df96d6b..cf84c109 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -89,10 +90,8 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.badge = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.badge = settings.getStringParam(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java index 520f28bf..d7dbfbcb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -69,7 +70,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java index b805c7b1..0f9d6c95 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -89,10 +90,9 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.teamColor = GameTeamColors.values()[packet.readInt()]; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]]; return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java index 027db810..b8376c01 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -91,10 +92,9 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.teamColor = GameTeamColors.values()[packet.readInt()]; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]]; return true; } 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 61e3fd70..0afdf18c 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 @@ -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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -118,11 +119,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -131,7 +129,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) { this.items.add(item); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java index f0a5b3f8..24a28885 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java @@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import com.google.gson.Gson; import java.sql.ResultSet; import java.sql.SQLException; @@ -49,11 +48,9 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String dataString = packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String dataString = settings.getStringParam(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index ee1b28b1..b46d0417 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -6,12 +6,12 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.procedure.TObjectProcedure; @@ -70,17 +70,18 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - int mode = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid"); + + int mode = settings.getIntParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String botName = packet.readString().replace("\t", ""); + String botName = settings.getStringParam().replace("\t", ""); botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - packet.readInt(); - int delay = packet.readInt(); + + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java index 27fc7888..5b380d3c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -13,7 +14,6 @@ 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.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; @@ -74,17 +74,17 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing item id"); - int itemId = packet.readInt(); + int itemId = settings.getIntParams()[0]; if(itemId < 0) itemId = 0; - String botName = packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + String botName = settings.getStringParam(); + + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java index 735b0f39..79fae2ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java @@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; @@ -52,15 +52,14 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - int mode = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid"); + int mode = settings.getIntParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String dataString = packet.readString(); + String dataString = settings.getStringParam(); String splitBy = "\t"; if(!dataString.contains(splitBy)) @@ -71,8 +70,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { if (data.length != 2) throw new WiredSaveException("Malformed data string. Invalid data length"); - packet.readInt(); - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index 8fede69c..ad0c8764 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -6,13 +6,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.procedure.TObjectProcedure; @@ -73,15 +73,14 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - int mode = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing mode"); + int mode = settings.getIntParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String dataString = packet.readString(); + String dataString = settings.getStringParam(); String splitBy = "\t"; if(!dataString.contains(splitBy)) throw new WiredSaveException("Malformed data string"); @@ -91,8 +90,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { if (data.length != 2) throw new WiredSaveException("Malformed data string. Invalid data length"); - packet.readInt(); - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java index 07bbac6f..822934a6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; @@ -114,10 +115,9 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String botName = packet.readString(); - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String botName = settings.getStringParam(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -126,7 +126,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -135,7 +135,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index 73906c87..b4b9d262 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -67,10 +68,9 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String botName = packet.readString(); - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String botName = settings.getStringParam(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -79,7 +79,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -88,7 +88,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 0ce892d7..7ee3859c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.*; @@ -210,9 +211,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - int startDirectionInt = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data"); + + int startDirectionInt = settings.getIntParams()[0]; if(startDirectionInt < 0 || startDirectionInt > 7 || (startDirectionInt % 2) != 0) { throw new WiredSaveException("Start direction is invalid"); @@ -220,15 +222,13 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionInt); - int blockedActionInt = packet.readInt(); + int blockedActionInt = settings.getIntParams()[1]; if(blockedActionInt < 0 || blockedActionInt > 6) { throw new WiredSaveException("Blocked action is invalid"); } - packet.readString(); - - int itemsCount = packet.readInt(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -237,7 +237,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { THashMap newItems = new THashMap<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -246,7 +246,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { newItems.put(it, new WiredChangeDirectionSetting(it.getId(), it.getRotation(), startDirection)); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 63920ffc..70911e39 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -67,17 +68,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { try { - this.amount = Integer.parseInt(packet.readString()); + this.amount = Integer.parseInt(settings.getStringParam()); } catch (Exception e) { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java index 0bd62164..d228c75e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -66,16 +67,14 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { try { - this.amount = Integer.valueOf(packet.readString()); + this.amount = Integer.parseInt(settings.getStringParam()); } catch (Exception e) { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + + this.setDelay(settings.getDelay()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java index 4a3b966f..91b78467 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -67,17 +68,14 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { try { - this.respects = Integer.valueOf(packet.readString()); + this.respects = Integer.parseInt(settings.getStringParam()); } catch (Exception e) { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java index f4c3a2ba..3c8fb88b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; @@ -15,6 +16,7 @@ import com.eu.habbo.habbohotel.wired.WiredGiveRewardItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; @@ -174,16 +176,16 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { if (gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) { - int argsLength = packet.readInt(); - this.rewardTime = packet.readInt(); - this.uniqueRewards = packet.readInt() == 1; - this.limit = packet.readInt(); - this.limitationInterval = packet.readInt(); + if(settings.getIntParams().length < 4) throw new WiredSaveException("Invalid data"); + this.rewardTime = settings.getIntParams()[0]; + this.uniqueRewards = settings.getIntParams()[1] == 1; + this.limit = settings.getIntParams()[2]; + this.limitationInterval = settings.getIntParams()[3]; this.given = 0; - String data = packet.readString(); + String data = settings.getStringParam(); String[] items = data.split(";"); @@ -204,8 +206,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); WiredHandler.dropRewards(this.getId()); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index 6632c2e4..293515cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -172,23 +173,20 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data"); - int score = packet.readInt(); + int score = settings.getIntParams()[0]; if(score < 1 || score > 100) throw new WiredSaveException("Score is invalid"); - int timesPerGame = packet.readInt(); + int timesPerGame = settings.getIntParams()[1]; if(timesPerGame < 1 || timesPerGame > 10) throw new WiredSaveException("Times per game is invalid"); - packet.readString(); - packet.readInt(); - - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index dcbc1481..a439a668 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.GameTeam; 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.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -121,28 +122,25 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data"); - int points = packet.readInt(); + int points = settings.getIntParams()[0]; if(points < 1 || points > 100) throw new WiredSaveException("Points is invalid"); - int timesPerGame = packet.readInt(); + int timesPerGame = settings.getIntParams()[1]; if(timesPerGame < 1 || timesPerGame > 10) throw new WiredSaveException("Times per game is invalid"); - int team = packet.readInt(); + int team = settings.getIntParams()[2]; if(team < 1 || team > 4) throw new WiredSaveException("Team is invalid"); - packet.readString(); - packet.readInt(); - - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java index 8d367009..28bd7c49 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -134,16 +135,15 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - int team = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data"); + + int team = settings.getIntParams()[0]; if(team < 1 || team > 4) throw new WiredSaveException("Team is invalid"); - packet.readInt(); - packet.readString(); - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java index e0f2ecd2..a75f2e3e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; @@ -148,11 +149,9 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String message = packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String message = settings.getStringParam(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java index deff061e..74830cfa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -116,11 +117,8 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 bb615d8d..8d74e312 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; @@ -175,21 +176,18 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - boolean setState = packet.readInt() == 1; - boolean setDirection = packet.readInt() == 1; - boolean setPosition = packet.readInt() == 1; - - packet.readString(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data"); + boolean setState = settings.getIntParams()[0] == 1; + boolean setDirection = settings.getIntParams()[1] == 1; + boolean setPosition = settings.getIntParams()[2] == 1; Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) throw new WiredSaveException("Trying to save wired in unloaded room"); - int itemsCount = packet.readInt(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -198,7 +196,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int List newSettings = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -207,7 +205,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int newSettings.add(new WiredMatchFurniSetting(it.getId(), this.checkForWiredResetPermission && it.allowWiredResetState() ? it.getExtradata() : " ", it.getRotation(), it.getX(), it.getY())); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 76fe1ed9..9f016a9e 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -178,10 +179,8 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -190,7 +189,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -199,7 +198,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 3b9367e2..4118fd05 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -12,6 +13,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -39,7 +41,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) @@ -48,18 +50,16 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { this.items.clear(); this.indexOffset.clear(); - packet.readInt(); + if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data"); + this.direction = settings.getIntParams()[0]; + this.spacing = settings.getIntParams()[1]; - this.direction = packet.readInt(); - this.spacing = packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } 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 c069dc93..89f56d3d 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -314,11 +315,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -327,7 +325,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -336,7 +334,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 5928e671..fd24af08 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 @@ -5,12 +5,14 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import org.slf4j.Logger; @@ -185,28 +187,26 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) return false; - packet.readInt(); + if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data"); - this.direction = packet.readInt(); - this.rotation = packet.readInt(); + this.direction = settings.getIntParams()[0]; + this.rotation = settings.getIntParams()[1]; - packet.readString(); - - int count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count", 5)) return false; this.items.clear(); for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } 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 39788018..ed3639a8 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; @@ -13,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import java.sql.ResultSet; @@ -49,12 +51,13 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - this.length = packet.readInt(); - this.message = packet.readString(); - packet.readInt(); - this.setDelay(packet.readInt()); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data"); + + this.length = settings.getIntParams()[0]; + this.message = settings.getStringParam(); + + this.setDelay(settings.getDelay()); return true; } 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 583e4f6a..826b8d31 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -67,13 +68,8 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - packet.readString(); - packet.readInt(); - this.delay = packet.readInt(); - this.setDelay(this.delay); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { + this.setDelay(settings.getDelay()); return true; } 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 304703f1..cf6197ad 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; @@ -130,11 +131,8 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -143,7 +141,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -152,7 +150,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 05eef1f3..7a3a0e16 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 @@ -17,6 +17,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -142,11 +143,8 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -155,7 +153,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -164,7 +162,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 4fbd9203..d5e60925 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 @@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -137,11 +138,8 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -150,7 +148,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -159,7 +157,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 db37872b..4f50f57f 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -85,11 +86,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -98,7 +96,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -107,7 +105,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 56d6f35e..79a7ba53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java @@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; @@ -70,19 +69,15 @@ public class WiredEffectWhisper extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - String message = packet.readString(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String message = settings.getStringParam(); if(gameClient.getHabbo() == null || !gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) { message = Emulator.getGameEnvironment().getWordFilter().filter(message, null); message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); } - packet.readInt(); - - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); 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 f6364641..60756729 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -110,9 +111,9 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.executeTime = packet.readInt() * 500; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.executeTime = settings.getIntParams()[0] * 500; this.resetTimer(); 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 751d21c7..7fdf0a2a 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 @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -109,10 +110,9 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.executeTime = packet.readInt() * 500; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.executeTime = settings.getIntParams()[0] * 500; return true; } 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 596fbc8f..3de2e345 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -97,17 +98,15 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.botName = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.botName = settings.getStringParam(); this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; 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 0e7b22fd..0023fb6d 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -48,10 +49,8 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.botName = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.botName = settings.getStringParam(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index 4e446609..a40bf2e1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -65,7 +66,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java index f97f332f..5d315e52 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -135,16 +136,13 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - + public boolean saveData(WiredSettings settings) { this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index abb84177..55ff097c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -83,7 +84,7 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index 5631cb46..89c9a657 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -83,7 +84,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index 9a1400b2..d93a1ba1 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -85,9 +86,8 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.username = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.username = settings.getStringParam(); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index f3b90ae3..d0bdd637 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -93,10 +94,10 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.ownerOnly = packet.readInt() == 1; - this.key = packet.readString(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.ownerOnly = settings.getIntParams()[0] == 1; + this.key = settings.getStringParam(); return true; } 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 64e9dae9..10b458b9 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -128,16 +129,13 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - + public boolean saveData(WiredSettings settings) { this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java index 257f23bb..d24be482 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 @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -82,16 +83,13 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - + public boolean saveData(WiredSettings settings) { this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 36d48b3e..f43ffac0 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -109,10 +110,9 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.repeatTime = packet.readInt() * 500; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.repeatTime = settings.getIntParams()[0] * 500; this.counter = 0; if (this.repeatTime < 500) { 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 ad93a09d..536aca86 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 @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -107,10 +108,9 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.repeatTime = packet.readInt() * 5000; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.repeatTime = settings.getIntParams()[0] * 5000; this.counter = 0; return true; } 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 1f558d88..463e5ba7 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 @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -85,9 +86,9 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.score = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.score = settings.getIntParams()[0]; return true; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java index 93972ee1..a7443e82 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java @@ -1,10 +1,13 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; public class WiredConditionSaveDataEvent extends MessageHandler { @@ -19,12 +22,16 @@ public class WiredConditionSaveDataEvent extends MessageHandler { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); if (condition != null) { - if (condition.saveData(this.packet)) { + WiredSettings settings = InteractionWired.readSettings(this.packet, false); + + if (condition.saveData(settings)) { this.client.sendResponse(new WiredSavedComposer()); condition.needsUpdate(true); Emulator.getThreading().run(condition); + } else { + this.client.sendResponse(new UpdateFailedComposer("There was an error while saving that condition")); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java index fbf51226..41de3dd9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java @@ -1,11 +1,12 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorMessagesComposer; import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; @@ -24,7 +25,8 @@ public class WiredEffectSaveDataEvent extends MessageHandler { if (effect == null) throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId)); - if (effect.saveData(this.packet, this.client)) { + WiredSettings settings = InteractionWired.readSettings(this.packet, true); + if (effect.saveData(settings, this.client)) { this.client.sendResponse(new WiredSavedComposer()); effect.needsUpdate(true); Emulator.getThreading().run(effect); diff --git a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java index 8f62f60e..5b3b25e5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java @@ -1,10 +1,13 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; public class WiredTriggerSaveDataEvent extends MessageHandler { @@ -19,12 +22,16 @@ public class WiredTriggerSaveDataEvent extends MessageHandler { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); if (trigger != null) { - if (trigger.saveData(this.packet)) { + WiredSettings settings = InteractionWired.readSettings(this.packet, false); + + if (trigger.saveData(settings)) { this.client.sendResponse(new WiredSavedComposer()); trigger.needsUpdate(true); Emulator.getThreading().run(trigger); + } else { + this.client.sendResponse(new UpdateFailedComposer("There was an error while saving that trigger")); } } } From e56d4eb7917c1cbdd3c59305ebf5e4e769877a3e Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 22 Mar 2022 12:47:06 +0100 Subject: [PATCH 73/94] Fixed interaction football valid moves --- .../games/football/InteractionFootball.java | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java index f64b0ade..6bd21167 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java @@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer; import com.eu.habbo.util.pathfinding.Rotation; +import java.math.BigDecimal; import java.sql.ResultSet; import java.sql.SQLException; @@ -151,7 +152,44 @@ public class InteractionFootball extends InteractionPushable { public boolean validMove(Room room, RoomTile from, RoomTile to) { if (to == null || to.state == RoomTileState.INVALID) return false; HabboItem topItem = room.getTopItemAt(to.x, to.y, this); - return (topItem == null || topItem.getBaseItem().allowStack()); + + // Move is valid if there isnt any furni yet + if (topItem == null) { + return true; + } + + // If any furni on tile is not stackable, move is invalid (tested on 22-03-2022) + if (room.getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) { + return false; + } + + // Ball can only go up by 1.65 according to Habbo (tested using stack tile on 22-03-2022) + BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight()); + BigDecimal ballHeight = BigDecimal.valueOf(this.getZ()); + + if (topItemHeight.subtract(ballHeight).compareTo(new BigDecimal(1.65)) > 0) { + return false; + } + + // If top item is a football goal, the move is only valid if ball is coming from the front side + // Ball shouldn't come from the back or from the sides (tested on 22-03-2022) + if (topItem instanceof InteractionFootballGoal) { + int ballDirection = Rotation.Calculate(from.x, from.y, to.x, to.y); + int goalRotation = topItem.getRotation(); + + switch (goalRotation) { + case 0: + return ballDirection > 2 && ballDirection < 6; + case 2: + return ballDirection > 4; + case 4: + return ballDirection > 6 || ballDirection < 2; + case 6: + return ballDirection > 0 && ballDirection < 4; + } + } + + return topItem.getBaseItem().allowStack(); } //Events From e3b0c62d5b697228fdf6ebcede57776a9b796481 Mon Sep 17 00:00:00 2001 From: dank074 Date: Tue, 22 Mar 2022 20:49:28 -0500 Subject: [PATCH 74/94] fix wired condition furni has avatars sending wrong data --- .../WiredConditionFurniHaveHabbo.java | 25 +++++------------ .../WiredConditionNotFurniHaveHabbo.java | 27 ++++++------------- 2 files changed, 15 insertions(+), 37 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 d26e3db5..6a2a70a5 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 @@ -25,8 +25,6 @@ import java.util.stream.Collectors; public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO; - - protected boolean all; protected THashSet items; public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { @@ -42,7 +40,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { @Override public void onPickUp() { this.items.clear(); - this.all = false; } @Override @@ -68,7 +65,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public String getWiredData() { this.refresh(); return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.all, this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @@ -80,7 +76,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.all = data.all; for(int id : data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -93,17 +88,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { String[] data = wiredData.split(":"); if (data.length >= 1) { - this.all = (data[0].equals("1")); - if (data.length == 2) { - String[] items = data[1].split(";"); + String[] items = data[1].split(";"); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); - if (item != null) - this.items.add(item); - } + if (item != null) + this.items.add(item); } } } @@ -128,8 +120,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); - message.appendInt(1); - message.appendInt(this.all ? 1 : 0); + message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -179,11 +170,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { } static class JsonData { - boolean all; List itemIds; - public JsonData(boolean all, List itemIds) { - this.all = all; + public JsonData(List itemIds) { this.itemIds = itemIds; } } 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 c046fde1..9409ebe8 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 @@ -25,8 +25,7 @@ import java.util.stream.Collectors; public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; - - protected boolean all; + protected THashSet items; public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { @@ -42,7 +41,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { @Override public void onPickUp() { this.items.clear(); - this.all = false; } @Override @@ -68,7 +66,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public String getWiredData() { this.refresh(); return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.all, this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @@ -80,7 +77,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { if (wiredData.startsWith("{")) { WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class); - this.all = data.all; for(int id : data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -93,17 +89,13 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { String[] data = wiredData.split(":"); if (data.length >= 1) { - this.all = (data[0].equals("1")); + String[] items = data[1].split(";"); - if (data.length == 2) { - String[] items = data[1].split(";"); + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } + if (item != null) + this.items.add(item); } } } @@ -128,8 +120,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); - message.appendInt(1); - message.appendInt(this.all ? 1 : 0); + message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -178,11 +169,9 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { } static class JsonData { - boolean all; List itemIds; - public JsonData(boolean all, List itemIds) { - this.all = all; + public JsonData(List itemIds) { this.itemIds = itemIds; } } From f81470f7ba5add2eaabe9119a06c9b02fbb98284 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Wed, 23 Mar 2022 03:28:23 +0100 Subject: [PATCH 75/94] No more empty gifts! --- .../catalog/CatalogBuyItemAsGiftEvent.java | 175 ++++++++---------- 1 file changed, 82 insertions(+), 93 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index d4093075..160f3e1a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -168,8 +168,13 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { item.sellRare(); } - int totalCredits = 0; - int totalPoints = 0; + int totalCredits = item.getCredits(); + int totalPoints = item.getPoints(); + + if(totalCredits > this.client.getHabbo().getHabboInfo().getCredits() || totalPoints > this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType())) { + this.client.sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); + return; + } CatalogLimitedConfiguration limitedConfiguration; int limitedStack = 0; @@ -224,103 +229,87 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { return; } - for (int i = 0; i < count; i++) { - if (item.getCredits() <= this.client.getHabbo().getHabboInfo().getCredits() - totalCredits) { - if ( - item.getPoints() <= this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()) - totalPoints) - //item.getPointsType() == 0 && item.getPoints() <= this.client.getHabbo().getHabboInfo().getPixels() - totalPoints || + if (item.getAmount() > 1 || item.getBaseItems().size() > 1) { + this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); + return; + } - { - if (((i + 1) % 6 != 0 && CatalogItem.haveOffer(item)) || !CatalogItem.haveOffer(item)) { - totalCredits += item.getCredits(); - totalPoints += item.getPoints(); - } + for (Item baseItem : item.getBaseItems()) { + if (item.getItemAmount(baseItem.getId()) > 1) { + this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); + return; + } - for (int j = 0; j < item.getAmount(); j++) { - if (item.getAmount() > 1 || item.getBaseItems().size() > 1) { - this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); - return; - } - for (Item baseItem : item.getBaseItems()) { - if (item.getItemAmount(baseItem.getId()) > 1) { - this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); - return; - } - - for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) { - if (!baseItem.getName().contains("avatar_effect")) { - if (baseItem.getType() == FurnitureType.BADGE) { - if (!badgeFound) { - if (habbo != null) { - HabboBadge badge = new HabboBadge(0, baseItem.getName(), 0, habbo); - Emulator.getThreading().run(badge); - habbo.getInventory().getBadgesComponent().addBadge(badge); - } else { - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, badge_code) VALUES (?, ?)")) { - statement.setInt(1, userId); - statement.setString(2, baseItem.getName()); - statement.execute(); - } - } - - badgeFound = true; - } - } else if (item.getName().startsWith("rentable_bot_")) { - this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); - return; - } else if (Item.isPet(baseItem)) { - this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); - return; - } else { - if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) { - if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && habbo != null && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) { - ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extraData)); - extraData = "UMAD"; - } - - extraData = this.client.getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + extraData; - } - - if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) { - HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId()); - itemsList.add(teleportOne); - itemsList.add(teleportTwo); - } else if (baseItem.getInteractionType().getType() == InteractionHopper.class) { - HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData); - - Emulator.getGameEnvironment().getItemManager().insertHopper(hopper); - - itemsList.add(hopper); - } else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) { - InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - habboItem.setExtradata(""); - habboItem.needsUpdate(true); - int guildId; - try { - guildId = Integer.parseInt(extraData); - } catch (Exception e) { - LOGGER.error("Caught exception", e); - this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); - return; - } - Emulator.getThreading().run(habboItem); - Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId); - itemsList.add(habboItem); - } else { - HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); - itemsList.add(habboItem); - } - } - } else { - this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); - this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("error.catalog.buy.not_yet"))); - return; + for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) { + if (!baseItem.getName().contains("avatar_effect")) { + if (baseItem.getType() == FurnitureType.BADGE) { + if (!badgeFound) { + if (habbo != null) { + HabboBadge badge = new HabboBadge(0, baseItem.getName(), 0, habbo); + Emulator.getThreading().run(badge); + habbo.getInventory().getBadgesComponent().addBadge(badge); + } else { + try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, badge_code) VALUES (?, ?)")) { + statement.setInt(1, userId); + statement.setString(2, baseItem.getName()); + statement.execute(); } } + + badgeFound = true; + } + } else if (item.getName().startsWith("rentable_bot_")) { + this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); + return; + } else if (Item.isPet(baseItem)) { + this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR).compose()); + return; + } else { + if (baseItem.getInteractionType().getType() == InteractionTrophy.class || baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class) { + if (baseItem.getInteractionType().getType() == InteractionBadgeDisplay.class && habbo != null && !habbo.getClient().getHabbo().getInventory().getBadgesComponent().hasBadge(extraData)) { + ScripterManager.scripterDetected(habbo.getClient(), Emulator.getTexts().getValue("scripter.warning.catalog.badge_display").replace("%username%", habbo.getClient().getHabbo().getHabboInfo().getUsername()).replace("%badge%", extraData)); + extraData = "UMAD"; + } + + extraData = this.client.getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + extraData; + } + + if (baseItem.getInteractionType().getType() == InteractionTeleport.class || baseItem.getInteractionType().getType() == InteractionTeleportTile.class) { + HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId()); + itemsList.add(teleportOne); + itemsList.add(teleportTwo); + } else if (baseItem.getInteractionType().getType() == InteractionHopper.class) { + HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedNumber, limitedNumber, extraData); + + Emulator.getGameEnvironment().getItemManager().insertHopper(hopper); + + itemsList.add(hopper); + } else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) { + InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + habboItem.setExtradata(""); + habboItem.needsUpdate(true); + int guildId; + try { + guildId = Integer.parseInt(extraData); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); + return; + } + Emulator.getThreading().run(habboItem); + Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId); + itemsList.add(habboItem); + } else { + HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData); + itemsList.add(habboItem); } } + } else { + this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); + this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("error.catalog.buy.not_yet"))); + return; } } } From e304ba1ecb36524518e68347191ab8bd9aa99055 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 23 Mar 2022 03:27:50 -0400 Subject: [PATCH 76/94] Revert change to EmptyInventoryCommand --- .../com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java index a7a205a8..66af755a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java @@ -42,6 +42,8 @@ public class EmptyInventoryCommand extends Command { Emulator.getThreading().run(new QueryDeleteHabboItems(items)); habbo.getClient().sendResponse(new InventoryRefreshComposer()); + habbo.getClient().sendResponse(new InventoryItemsComposer(0, 1, gameClient.getHabbo().getInventory().getItemsComponent().getItems())); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT); } else { From b668bfd99a2d5484025d92fb78dfba64fef43301 Mon Sep 17 00:00:00 2001 From: dank074 Date: Wed, 23 Mar 2022 03:15:25 -0500 Subject: [PATCH 77/94] add moodlight color config --- sqlupdates/3_0_0 to 3_0_1.sql | 3 +++ .../incoming/rooms/items/MoodLightSaveSettingsEvent.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlupdates/3_0_0 to 3_0_1.sql b/sqlupdates/3_0_0 to 3_0_1.sql index 248827a8..e48d67a3 100644 --- a/sqlupdates/3_0_0 to 3_0_1.sql +++ b/sqlupdates/3_0_0 to 3_0_1.sql @@ -80,3 +80,6 @@ ALTER TABLE `permissions` ADD COLUMN `acc_calendar_force` enum('0','1') NULL DEF ALTER TABLE `permissions` ADD `cmd_update_calendar` ENUM('0', '1') NOT NULL DEFAULT '0'; INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_update_calendar', ':update_calendar'), ('commands.keys.cmd_update_calendar', 'update_calendar'); INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.success.cmd_update_calendar', 'Calendar updated successfully!'); + +-- add moodlight configuration +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('moodlight.color_check.enabled', '1'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index 731e6490..894e83c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -30,7 +30,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { int brightness = this.packet.readInt(); boolean apply = this.packet.readBoolean(); - if (!MOODLIGHT_AVAILABLE_COLORS.contains(color)) { + if (Emulator.getConfig().getBoolean("moodlight.color_check.enabled", true) && !MOODLIGHT_AVAILABLE_COLORS.contains(color)) { ScripterManager.scripterDetected(this.client, "User tried to set a moodlight to a non-whitelisted color: " + color); return; } From 208c07a809701c167b1df10f9984ad35fae72b11 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 23 Mar 2022 04:43:39 -0400 Subject: [PATCH 78/94] Add bot motto max length to match user --- .../messages/incoming/rooms/bots/BotSaveSettingsEvent.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java index 2d217924..bb5da19d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java @@ -152,7 +152,11 @@ public class BotSaveSettingsEvent extends MessageHandler { } break; case 9: - bot.setMotto(this.packet.readString()); + String motto = this.packet.readString(); + + if(motto.length() > Emulator.getConfig().getInt("motto.max_length", 38)) break; + + bot.setMotto(motto); bot.needsUpdate(true); room.sendComposer(new RoomUsersComposer(bot).compose()); break; From 8eacb5b977272c9a7db1cf3423b40be4082a86a8 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Wed, 23 Mar 2022 17:50:32 -0300 Subject: [PATCH 79/94] Update CalendarRewardClaimed.java --- .../habbohotel/campaign/calendar/CalendarRewardClaimed.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java index 3cc0c56d..7b6a1837 100644 --- a/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java +++ b/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarRewardClaimed.java @@ -16,7 +16,7 @@ public class CalendarRewardClaimed { this.campaign = set.getInt("campaign_id"); this.day = set.getInt("day"); this.reward_id = set.getInt("reward_id"); - this.timestamp = set.getTimestamp("timestamp"); + this.timestamp = new Timestamp(set.getInt("timestamp") * 1000L); } public CalendarRewardClaimed(int user_id, int campaign, int day, int reward_id, Timestamp timestamp) { From b0b213cfb3864fe38d3859b2053e040dfaf39c30 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Wed, 23 Mar 2022 18:20:27 -0300 Subject: [PATCH 80/94] Fix doorbell --- .../eu/habbo/messages/incoming/hotelview/HotelViewEvent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java index a1560542..67dddaa3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewEvent.java @@ -3,6 +3,7 @@ package com.eu.habbo.messages.incoming.hotelview; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.hotelview.HotelViewComposer; public class HotelViewEvent extends MessageHandler { @Override @@ -21,6 +22,7 @@ public class HotelViewEvent extends MessageHandler { } else { this.client.getHabbo().getHabboInfo().setRoomQueueId(0); } + this.client.sendResponse(new HotelViewComposer()); } if (this.client.getHabbo().getRoomUnit() != null) { From 9db71ac972953eac70713de8df0ec22caa28a0ee Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Wed, 23 Mar 2022 21:24:23 -0300 Subject: [PATCH 81/94] Fix summon commands --- .../habbohotel/commands/SummonCommand.java | 20 +++++++++---------- .../commands/SummonRankCommand.java | 15 ++++++++++++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java index 727d3fe2..3bb7ae87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; @@ -36,22 +37,21 @@ public class SummonCommand extends Command { return true; } - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summon.summoning").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); + Room room = habbo.getHabboInfo().getCurrentRoom(); + if (room != null) { + Emulator.getGameEnvironment().getRoomManager().logExit(habbo); - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, habbo.getHabboInfo().getCurrentRoom()); + room.removeHabbo(habbo, true); + + habbo.getHabboInfo().setCurrentRoom(null); + } + + Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); habbo.getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId())); - Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); - habbo.getClient().sendResponse(new HideDoorbellComposer("")); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_summon.summoned").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - RoomTile t = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue()); - - if (t != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().tileWalkable(t)) { - habbo.getRoomUnit().setGoalLocation(t); - } - habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername())); return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java index 8dd8a070..d2c1252c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; @@ -33,9 +34,19 @@ public class SummonRankCommand extends Command { if (set.getValue().getHabboInfo().getCurrentRoom() == gameClient.getHabbo().getHabboInfo().getCurrentRoom()) continue; - Emulator.getGameEnvironment().getRoomManager().leaveRoom(set.getValue(), set.getValue().getHabboInfo().getCurrentRoom()); - set.getValue().getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId())); + Room room = set.getValue().getHabboInfo().getCurrentRoom(); + if (room != null) { + Emulator.getGameEnvironment().getRoomManager().logExit(set.getValue()); + + room.removeHabbo(set.getValue(), true); + + set.getValue().getHabboInfo().setCurrentRoom(null); + } + Emulator.getGameEnvironment().getRoomManager().enterRoom(set.getValue(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true); + + set.getValue().getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId())); + } } } From 2cc8a195b4cb6f2b7bb8ae522ad6d03eb5d3698d Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Wed, 23 Mar 2022 21:31:45 -0300 Subject: [PATCH 82/94] remove unused imports --- .../java/com/eu/habbo/habbohotel/commands/SummonCommand.java | 2 -- .../com/eu/habbo/habbohotel/commands/SummonRankCommand.java | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java index 3bb7ae87..b362f5a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonCommand.java @@ -4,10 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; -import com.eu.habbo.messages.outgoing.rooms.HideDoorbellComposer; public class SummonCommand extends Command { public SummonCommand() { diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java index d2c1252c..16312bd5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/SummonRankCommand.java @@ -20,7 +20,7 @@ public class SummonRankCommand extends Command { if (params.length >= 2) { try { - minRank = Integer.valueOf(params[1]); + minRank = Integer.parseInt(params[1]); } catch (Exception e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summonrank.error"), RoomChatMessageBubbles.ALERT); return true; From 06969df00a1ff9cd626fb01e61ea3a54d662e781 Mon Sep 17 00:00:00 2001 From: ArpyAge Date: Sun, 27 Mar 2022 16:06:07 +0200 Subject: [PATCH 83/94] Redeem command fix for CF_diamond_ furniture --- .../com/eu/habbo/habbohotel/commands/RedeemCommand.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java index 21db5c7f..9d389474 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java @@ -51,6 +51,15 @@ public class RedeemCommand extends Command { pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount); + } + else if (item.getBaseItem().getName().startsWith("CF_diamond_")) { + int pointsType; + int pointsAmount; + + pointsType = 5; + pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); + points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount); } } From a9de571426b21f78442a401132555551e8ad71a2 Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Thu, 31 Mar 2022 08:36:26 +0000 Subject: [PATCH 84/94] Removed old links, and Re-wrote the startup. --- src/main/java/com/eu/habbo/Emulator.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index cb030b18..91748e7f 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -119,8 +119,7 @@ public final class Emulator { LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); LOGGER.info("Version: {}", version); LOGGER.info("Build: {}", build); - LOGGER.info("Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq"); - LOGGER.info("Join our discord at https://discord.gg/syuqgN"); + LOGGER.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community"); long startTime = System.nanoTime(); From 745dbed6aa415a88232f980eda340ac7bdfa14e4 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sat, 2 Apr 2022 13:27:40 +0100 Subject: [PATCH 85/94] Fix SQL Exceptions on Market Place --- .../habbohotel/catalog/marketplace/MarketPlace.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index 7ac720d8..ec8dadfb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -177,7 +177,7 @@ public class MarketPlace { public static void serializeItemInfo(int itemId, ServerMessage message) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { statement.setInt(1, itemId); message.appendInt(avarageLastXDays(itemId, 7)); @@ -206,7 +206,7 @@ public class MarketPlace { public static int itemsOnSale(int baseItemId) { int number = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as number, AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 1 AND timestamp >= ? AND items_base.sprite_id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as number, AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 1 AND timestamp >= ? AND items_base.sprite_id = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { statement.setInt(1, Emulator.getIntUnixTimestamp() - 172800); statement.setInt(2, baseItemId); try (ResultSet set = statement.executeQuery()) { @@ -223,7 +223,7 @@ public class MarketPlace { private static int avarageLastXDays(int baseItemId, int days) { int avg = 0; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 2 AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL ? DAY AND items_base.sprite_id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 2 AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL ? DAY AND items_base.sprite_id = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { statement.setInt(1, days); statement.setInt(2, baseItemId); @@ -246,7 +246,7 @@ public class MarketPlace { statement.setInt(1, offerId); try (ResultSet set = statement.executeQuery()) { if (set.next()) { - try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) { + try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { itemStatement.setInt(1, set.getInt("item_id")); try (ResultSet itemSet = itemStatement.executeQuery()) { itemSet.first(); @@ -315,7 +315,7 @@ public class MarketPlace { "FROM items_base\n" + "WHERE items_base.id = ? LIMIT 1)\n" + "ORDER BY price ASC\n" + - "LIMIT 1")) { + "LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { statement.setInt(1, baseItemId); try (ResultSet countSet = statement.executeQuery()) { countSet.last(); From 57897c14c05ad1a7c088129e59601623721c36f6 Mon Sep 17 00:00:00 2001 From: xjoaoppf Date: Mon, 4 Apr 2022 16:02:07 +0000 Subject: [PATCH 86/94] Fixed WordFilter Code --- src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index 791d12d5..8cd83a3c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -79,7 +79,7 @@ public class WordFilter { return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD) .replaceAll("[,.;:'\"]", " ").replace("I", "l") .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", " ") - .replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i") + .replaceAll("[^\\p{M}*$]", "").replaceAll("[1|]", "i") .replace("2", "z").replace("3", "e") .replace("4", "a").replace("5", "s") .replace("8", "b").replace("0", "o") From eaa915e7f7e3900d01368f1fe941b33f7ec8fe27 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 9 Apr 2022 01:18:38 +0000 Subject: [PATCH 87/94] Upload New File --- ...nteractionEffectVendingMachineNoSides.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java new file mode 100644 index 00000000..799c2116 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java @@ -0,0 +1,43 @@ +package com.eu.habbo.habbohotel.items.interactions; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import gnu.trove.set.hash.THashSet; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionEffectVendingMachineNoSides extends InteractionVendingMachine { + public InteractionEffectVendingMachineNoSides(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + this.setExtradata("0"); + } + + public InteractionEffectVendingMachineNoSides(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + this.setExtradata("0"); + } + + @Override + public void giveVendingMachineItem(Room room, RoomUnit unit) { + room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30); + } + + @Override + public THashSet getActivatorTiles(Room room) { + + THashSet tiles = new THashSet(); + for(int x = -1; x <= 1; x++) { + for(int y = -1; y <= 1; y++) { + RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y)); + if(tile != null) { + tiles.add(tile); + } + } + } + + return tiles; + } +} \ No newline at end of file From 451422b328ee34bf733a6531eff8c2abd916ae6f Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 9 Apr 2022 01:21:19 +0000 Subject: [PATCH 88/94] Added effect_vendingmachine_no_sides --- src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index e62b1f0a..16ec285d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -180,6 +180,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("handitem_tile", InteractionHanditemTile.class)); this.interactionsList.add(new ItemInteraction("effect_giver", InteractionEffectGiver.class)); this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class)); + this.interactionsList.add(new ItemInteraction("effect_vendingmachine_no_sides", InteractionEffectVendingMachineNoSides.class)); this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class)); this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class)); this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class)); From d591c3f5f0fbe7d45d5522fca6ccbb5fa08c045c Mon Sep 17 00:00:00 2001 From: oshawott Date: Sun, 10 Apr 2022 01:18:52 +0000 Subject: [PATCH 89/94] Update Voucher.java --- src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java index b5e93b13..468e2a2b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -38,7 +38,8 @@ public class Voucher { } private void loadHistory() { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM voucher_history")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM voucher_history WHERE voucher_id = ?")) { + statement.setInt(1, this.id); try (ResultSet set = statement.executeQuery()) { while (set.next()) { this.history.add(new VoucherHistoryEntry(set)); From b1ea3dfd664c2d0f4f4677f21462707a9d89ea6a Mon Sep 17 00:00:00 2001 From: AlfreviD Date: Sun, 10 Apr 2022 16:07:50 +0000 Subject: [PATCH 90/94] Fix Issue #948 --- .../com/eu/habbo/habbohotel/rooms/Room.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 09c54558..f0c214ca 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4124,15 +4124,23 @@ public class Room implements Comparable, ISerialize, Runnable { } public void giveEffect(RoomUnit roomUnit, int effectId, int duration) { - if (duration == -1 || duration == Integer.MAX_VALUE) { - duration = Integer.MAX_VALUE; - } else { - duration += Emulator.getIntUnixTimestamp(); - } + if(roomUnit == null) return; - if (this.allowEffects && roomUnit != null) { - roomUnit.setEffectId(effectId, duration); - this.sendComposer(new RoomUserEffectComposer(roomUnit).compose()); + Habbo habbo = roomUnit.getRoom().getHabbo(roomUnit); + + if(habbo == null) return; + + if (!habbo.getHabboInfo().isInGame()) { + if (duration == -1 || duration == Integer.MAX_VALUE) { + duration = Integer.MAX_VALUE; + } else { + duration += Emulator.getIntUnixTimestamp(); + } + + if (this.allowEffects) { + roomUnit.setEffectId(effectId, duration); + this.sendComposer(new RoomUserEffectComposer(roomUnit).compose()); + } } } From 52be0b45a0eed13853a0df72c8125309c71e8880 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 10 Apr 2022 09:56:28 -0700 Subject: [PATCH 91/94] Fixed daily respects and scratches not showing without reload. (nttzx) --- src/main/java/com/eu/habbo/core/CleanerThread.java | 2 ++ src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/eu/habbo/core/CleanerThread.java b/src/main/java/com/eu/habbo/core/CleanerThread.java index 10dcc784..e9e2f122 100644 --- a/src/main/java/com/eu/habbo/core/CleanerThread.java +++ b/src/main/java/com/eu/habbo/core/CleanerThread.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.friends.SearchUserEvent; import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent; +import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.eu.habbo.threading.runnables.AchievementUpdater; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -146,6 +147,7 @@ public class CleanerThread implements Runnable { for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) { habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect"); habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets"); + habbo.getClient().sendResponse(new UserDataComposer(habbo)); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java index 078f7143..3ffa2621 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java @@ -2,6 +2,7 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.google.gson.Gson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,6 +27,7 @@ public class GiveRespect extends RCONMessage { habbo.getHabboStats().respectPointsReceived += object.respect_received; habbo.getHabboStats().respectPointsGiven += object.respect_given; habbo.getHabboStats().respectPointsToGive += object.daily_respects; + habbo.getClient().sendResponse(new UserDataComposer(habbo)); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET respects_given = respects_give + ?, respects_received = respects_received + ?, daily_respect_points = daily_respect_points + ? WHERE user_id = ? LIMIT 1")) { statement.setInt(1, object.respect_received); From 37abd2aadb37dcc6126fb9a6e76a00e7bde5a852 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 10 Apr 2022 10:45:23 -0700 Subject: [PATCH 92/94] Added "Atcg" Achievement on crafting --- .../incoming/crafting/CraftingCraftItemEvent.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java index 02936f01..3887c6a0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/crafting/CraftingCraftItemEvent.java @@ -54,17 +54,16 @@ public class CraftingCraftItemEvent extends MessageHandler { if (!recipe.getAchievement().isEmpty()) { AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(recipe.getAchievement())); + } this.client.sendResponse(new CraftingResultComposer(recipe)); this.client.getHabbo().getInventory().getItemsComponent().addItem(rewardItem); this.client.sendResponse(new AddHabboItemComposer(rewardItem)); - toRemove.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(HabboItem object) { - CraftingCraftItemEvent.this.client.sendResponse(new RemoveHabboItemComposer(object.getGiftAdjustedId())); - return true; - } + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Atcg")); + toRemove.forEachValue(object -> { + CraftingCraftItemEvent.this.client.sendResponse(new RemoveHabboItemComposer(object.getGiftAdjustedId())); + return true; }); this.client.sendResponse(new InventoryRefreshComposer()); From fa266af82d029915fd0dce5c3970e3f147626dcc Mon Sep 17 00:00:00 2001 From: AlfreviD Date: Sun, 10 Apr 2022 18:27:05 +0000 Subject: [PATCH 93/94] Fix Issue #824 --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 2 +- 1 file changed, 1 insertion(+), 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 05ddc66a..1d71cf81 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -1312,7 +1312,7 @@ public class RoomManager { if (friend == null || friend.getHabboInfo() == null) continue; Room room = friend.getHabboInfo().getCurrentRoom(); - if (room != null && !rooms.contains(room)) rooms.add(room); + if (room != null && !rooms.contains(room) && room.hasRights(habbo)) rooms.add(room); if (rooms.size() >= limit) break; } From 375f6a0e42c699bc9256b7c4a3a83e0ba3898be1 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 10 Apr 2022 17:11:25 -0700 Subject: [PATCH 94/94] Fixed Guilds so group admins can accept and remove group members. --- .../guilds/GuildAcceptMembershipEvent.java | 61 ++++++++++--------- .../guilds/GuildConfirmRemoveMemberEvent.java | 2 +- .../guilds/GuildDeclineMembershipEvent.java | 2 +- .../guilds/GuildRemoveMemberEvent.java | 2 +- .../outgoing/guilds/GuildInfoComposer.java | 47 +++++++------- 5 files changed, 58 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java index 1f932ffb..068aba2e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildAcceptMembershipEvent.java @@ -20,43 +20,44 @@ public class GuildAcceptMembershipEvent extends MessageHandler { int userId = this.packet.readInt(); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); - - if (guild == null || (guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).containsKey(this.client.getHabbo().getHabboInfo().getId()) && !this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN))) - return; - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) { - if (habbo.getHabboStats().hasGuild(guild.getId())) { - this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED)); - return; - } else { - //Check the user has requested - GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo); - if (member == null || member.getRank().type != GuildRank.REQUESTED.type) { - this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER)); - return; - } else { - GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo); - Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled()) { - habbo.getHabboStats().addGuild(guild.getId()); - Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true); - guild.decreaseRequestCount(); - guild.increaseMemberCount(); - this.client.sendResponse(new GuildRefreshMembersListComposer(guild)); - Room room = habbo.getHabboInfo().getCurrentRoom(); - if (room != null) { - if (room.getGuildId() == guildId) { - habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); - room.refreshRightsForHabbo(habbo); + if (guild != null) { + GuildMember groupMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || groupMember.getRank().equals(GuildRank.ADMIN) || groupMember.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { + if (habbo != null) { + if (habbo.getHabboStats().hasGuild(guild.getId())) { + this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED)); + return; + } else { + //Check the user has requested + GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo); + if (member == null || member.getRank().type != GuildRank.REQUESTED.type) { + this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER)); + return; + } else { + GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo); + Emulator.getPluginManager().fireEvent(event); + if (!event.isCancelled()) { + habbo.getHabboStats().addGuild(guild.getId()); + Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true); + guild.decreaseRequestCount(); + guild.increaseMemberCount(); + this.client.sendResponse(new GuildRefreshMembersListComposer(guild)); + Room room = habbo.getHabboInfo().getCurrentRoom(); + if (room != null) { + if (room.getGuildId() == guildId) { + habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); + room.refreshRightsForHabbo(habbo); + } + } } } } + } else { + Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true); } } - } else { - Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java index 0daebeab..ba569387 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java @@ -19,7 +19,7 @@ public class GuildConfirmRemoveMemberEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.OWNER)) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN)) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); int count = 0; if (room != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java index d75a5ef1..885e771c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java @@ -23,7 +23,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)|| member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { guild.decreaseRequestCount(); Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, ""))); 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 7ee21067..dcde989f 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 @@ -24,7 +24,7 @@ public class GuildRemoveMemberEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo); Emulator.getPluginManager().fireEvent(removedMemberEvent); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java index 768e85ba..dab0c0e7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java @@ -1,5 +1,6 @@ package com.eu.habbo.messages.outgoing.guilds; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.GuildMember; @@ -28,28 +29,28 @@ public class GuildInfoComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { - boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN); - this.response.init(Outgoing.GuildInfoComposer); - this.response.appendInt(this.guild.getId()); - this.response.appendBoolean(true); - this.response.appendInt(this.guild.getState().state); - this.response.appendString(this.guild.getName()); - this.response.appendString(this.guild.getDescription()); - this.response.appendString(this.guild.getBadge()); - this.response.appendInt(this.guild.getRoomId()); - this.response.appendString(this.guild.getRoomName()); - this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus()); - this.response.appendInt(this.guild.getMemberCount()); - this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group - this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); - this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); - this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); + boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN) || Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(this.client.getHabbo().getHabboInfo().getId()) != null; + this.response.init(Outgoing.GuildInfoComposer); + this.response.appendInt(this.guild.getId()); + this.response.appendBoolean(true); + this.response.appendInt(this.guild.getState().state); + this.response.appendString(this.guild.getName()); + this.response.appendString(this.guild.getDescription()); + this.response.appendString(this.guild.getBadge()); + this.response.appendInt(this.guild.getRoomId()); + this.response.appendString(this.guild.getRoomName()); + this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus()); + this.response.appendInt(this.guild.getMemberCount()); + this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group + this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); + this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); + this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); - this.response.appendString(this.guild.getOwnerName()); - this.response.appendBoolean(this.newWindow); - this.response.appendBoolean(this.guild.getRights()); - this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count. - this.response.appendBoolean(this.guild.hasForum()); - return this.response; + this.response.appendString(this.guild.getOwnerName()); + this.response.appendBoolean(this.newWindow); + this.response.appendBoolean(this.guild.getRights()); + this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count. + this.response.appendBoolean(this.guild.hasForum()); + return this.response; + } } -}