From ba6a849972c51805e8b0739a57c93d8341900e1b Mon Sep 17 00:00:00 2001 From: xjoao Date: Thu, 20 Jan 2022 12:06:04 +0000 Subject: [PATCH 01/11] 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 5e9b9c7f30b6f903aafff132bbee4bb9eb4d0fc6 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sat, 19 Mar 2022 17:08:15 +0000 Subject: [PATCH 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 11/11] 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; + } +}