From f3567f6714be21b0786ae449592014b8ac9bc76f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 16 May 2019 16:56:20 +0300 Subject: [PATCH 1/6] Add subscription boxes --- sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql | 4 +++ .../habbohotel/items/CrackableReward.java | 9 +++++++ .../habbo/habbohotel/items/ItemManager.java | 1 + .../items/RedeemableSubscriptionType.java | 24 +++++++++++++++++ .../interactions/InteractionCrackable.java | 26 +++++++++++++++++- .../InteractionRedeemableSubscriptionBox.java | 27 +++++++++++++++++++ .../threading/runnables/CrackableExplode.java | 2 +- 7 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java diff --git a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql index 7435cb55..9c90be02 100644 --- a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql +++ b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql @@ -8,4 +8,8 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('scripter.modtool.tickets', '1'); +ALTER TABLE `items_crackable` +ADD COLUMN `subscription_duration` int(3) NULL AFTER `required_effect`, +ADD COLUMN `subscription_type` varchar(255) NULL COMMENT 'hc for Habbo Club, bc for Builders Club' AFTER `subscription_duration`; + #END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3 \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java index fe8dfbec..ef8d53b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -17,6 +17,8 @@ public class CrackableReward public final String achievementTick; public final String achievementCracked; public final int requiredEffect; + public final int subscriptionDuration; + public final RedeemableSubscriptionType subscriptionType; public CrackableReward(ResultSet set) throws SQLException { @@ -25,10 +27,15 @@ public class CrackableReward this.achievementTick = set.getString("achievement_tick"); this.achievementCracked = set.getString("achievement_cracked"); this.requiredEffect = set.getInt("required_effect"); + this.subscriptionDuration = set.getInt("subscription_duration"); + this.subscriptionType = RedeemableSubscriptionType.fromString(set.getString("subscription_type")); + String[] prizes = set.getString("prizes").split(";"); this.prizes = new HashMap<>(); + if (set.getString("prizes").isEmpty()) return; + this.totalChance = 0; for (String prize : prizes) { @@ -59,6 +66,8 @@ public class CrackableReward public int getRandomReward() { + if (this.prizes.size() == 0) return 0; + int random = Emulator.getRandom().nextInt(this.totalChance); int notFound = 0; 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 98c050c3..cfeef773 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -175,6 +175,7 @@ public class ItemManager this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class)); this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class)); this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class)); + this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java new file mode 100644 index 00000000..ac58d5ce --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java @@ -0,0 +1,24 @@ +package com.eu.habbo.habbohotel.items; + +public enum RedeemableSubscriptionType { + HABBO_CLUB("hc"), + BUILDERS_CLUB("bc"); + + public final String subscriptionType; + + RedeemableSubscriptionType(String subscriptionType) + { + this.subscriptionType = subscriptionType; + } + + public static RedeemableSubscriptionType fromString(String subscriptionType) { + switch (subscriptionType) { + case "hc": + return HABBO_CLUB; + case "bc": + return BUILDERS_CLUB; + } + + return null; + } +} 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 e4598517..5a3c80fe 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 @@ -11,6 +11,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.users.UserClubComposer; +import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer; import com.eu.habbo.threading.runnables.CrackableExplode; import com.eu.habbo.util.pathfinding.Rotation; @@ -77,7 +79,7 @@ public class InteractionCrackable extends HabboItem if (this.cracked) return; - if (client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) + if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) { client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY()))); return; @@ -129,6 +131,24 @@ public class InteractionCrackable extends HabboItem { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked)); } + + if (rewardData.subscriptionType != null && rewardData.subscriptionDuration > 0) { + // subscriptions are given immediately upon cracking + switch (rewardData.subscriptionType) { + case HABBO_CLUB: + if (habbo.getHabboStats().getClubExpireTimestamp() <= Emulator.getIntUnixTimestamp()) + habbo.getHabboStats().setClubExpireTimestamp(Emulator.getIntUnixTimestamp()); + + habbo.getHabboStats().setClubExpireTimestamp(habbo.getHabboStats().getClubExpireTimestamp() + (rewardData.subscriptionDuration * 86400)); + habbo.getClient().sendResponse(new UserPermissionsComposer(habbo)); + habbo.getClient().sendResponse(new UserClubComposer(habbo)); + habbo.getHabboStats().run(); + break; + case BUILDERS_CLUB: + habbo.alert("Builders club has not been implemented yet. Sorry!"); + break; + } + } } } } @@ -167,6 +187,10 @@ public class InteractionCrackable extends HabboItem return false; } + public boolean userRequiredToBeAdjacent() { + return true; + } + public void reset(Room room) { this.cracked = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java new file mode 100644 index 00000000..a0f2da01 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java @@ -0,0 +1,27 @@ +package com.eu.habbo.habbohotel.items.interactions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.RedeemableSubscriptionType; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.users.UserClubComposer; +import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionRedeemableSubscriptionBox extends InteractionCrackable { + public InteractionRedeemableSubscriptionBox(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionRedeemableSubscriptionBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + public boolean userRequiredToBeAdjacent() { + return false; + } +} 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 012a61bd..2ef1e34d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CrackableExplode.java @@ -42,7 +42,7 @@ public class CrackableExplode implements Runnable if (!this.habboItem.resetable()) { this.room.removeHabboItem(this.habboItem); - this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem).compose()); + this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose()); this.habboItem.setRoomId(0); Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem); } From 8d7d5264e591b84e204e2733fe8fb8447c69bb8c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 16 May 2019 19:46:37 +0300 Subject: [PATCH 2/6] Closes #28 --- sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql | 3 +++ src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql index f6e347dd..6769fd62 100644 --- a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql +++ b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql @@ -8,4 +8,7 @@ ADD COLUMN `build_hash` varchar(64) NOT NULL AFTER `version`; INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('scripter.modtool.tickets', '1'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('invisible.prevent.chat', '0'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('invisible.prevent.chat.error', 'While being invisible you cannot talk.'); + #END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3 \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 6e0243ed..66a347e5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3711,6 +3711,14 @@ public class Room implements Comparable, ISerialize, Runnable if (!habbo.getHabboStats().allowTalk()) return; + if (habbo.getRoomUnit().isInvisible() && Emulator.getConfig().getBoolean("invisible.prevent.chat", false)) { + if (!CommandHandler.handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { + habbo.whisper(Emulator.getTexts().getValue("invisible.prevent.chat.error")); + } + + return; + } + habbo.getHabboStats().chatCounter += 2; if (habbo.getHabboInfo().getCurrentRoom() != this) From 2b02012ecd5b7305404f70335f7f6e015f058302 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 16 May 2019 20:11:11 +0300 Subject: [PATCH 3/6] Make invisible command toggleable --- sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql | 2 ++ .../habbohotel/commands/InvisibleCommand.java | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql index 6769fd62..693b0804 100644 --- a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql +++ b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql @@ -11,4 +11,6 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('scripter.modtool.ticket INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('invisible.prevent.chat', '0'); INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('invisible.prevent.chat.error', 'While being invisible you cannot talk.'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.succes.cmd_invisible.updated.back', 'You are now visible again.'); + #END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3 \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java index 464f33b3..8be82b99 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java @@ -2,8 +2,14 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; public class InvisibleCommand extends Command { @@ -17,10 +23,30 @@ public class InvisibleCommand extends Command { RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit(); + if (roomUnit.isInvisible()) { + RoomLayout roomLayout = roomUnit.getRoom().getLayout(); + + roomUnit.setLocation(roomLayout.getDoorTile()); + roomUnit.clearStatus(); + roomUnit.clearWalking(); + roomUnit.setBodyRotation(RoomUserRotation.values()[roomLayout.getDoorDirection()]); + roomUnit.setHeadRotation(RoomUserRotation.values()[roomLayout.getDoorDirection()]); + roomUnit.setInvisible(false); + roomUnit.setInRoom(true); + + roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose()); + roomUnit.getRoom().sendComposer(new RoomUserStatusComposer(roomUnit).compose()); + + WiredHandler.handle(WiredTriggerType.ENTER_ROOM, roomUnit, roomUnit.getRoom(), null); + roomUnit.getRoom().habboEntered(gameClient.getHabbo()); + + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated.back")); + + return true; + } + roomUnit.setInvisible(true); - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated")); - gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRemoveComposer(roomUnit).compose()); return true; From 3161188c4593dc63e11de9eae7b50fde323d2a48 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 16 May 2019 20:46:25 +0300 Subject: [PATCH 4/6] Fix invisible command in certain cases --- .../eu/habbo/habbohotel/commands/InvisibleCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java index 8be82b99..876708b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java @@ -3,13 +3,16 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; +import com.eu.habbo.threading.runnables.RoomUnitTeleport; public class InvisibleCommand extends Command { @@ -26,11 +29,8 @@ public class InvisibleCommand extends Command if (roomUnit.isInvisible()) { RoomLayout roomLayout = roomUnit.getRoom().getLayout(); - roomUnit.setLocation(roomLayout.getDoorTile()); - roomUnit.clearStatus(); - roomUnit.clearWalking(); - roomUnit.setBodyRotation(RoomUserRotation.values()[roomLayout.getDoorDirection()]); - roomUnit.setHeadRotation(RoomUserRotation.values()[roomLayout.getDoorDirection()]); + new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().x, roomLayout.getDoorTile().y, roomLayout.getDoorTile().z, 0).run(); + roomUnit.setInvisible(false); roomUnit.setInRoom(true); From fc02123bd151f09541d02c08ff6913b90913ceb8 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 16 May 2019 21:01:11 +0300 Subject: [PATCH 5/6] Fix RedeemableSubscriptionType NullPointer --- .../eu/habbo/habbohotel/items/RedeemableSubscriptionType.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java index ac58d5ce..e16cf981 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/RedeemableSubscriptionType.java @@ -12,6 +12,8 @@ public enum RedeemableSubscriptionType { } public static RedeemableSubscriptionType fromString(String subscriptionType) { + if (subscriptionType == null) return null; + switch (subscriptionType) { case "hc": return HABBO_CLUB; From 59f5b406dee216f82e87d4a93156219cf995bae1 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Thu, 16 May 2019 19:39:07 -0400 Subject: [PATCH 6/6] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cf501d89..17618274 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ When making an bug report or a feature request use the template we provide so th - Harmonic - Beny - Claudio +- Alejandro +- Harmony ## Discord ## Join us on Discord at https://discord.gg/BzfFsTp