From 3f8762f7bbe68eaa0d4ec335ad3be28316288e22 Mon Sep 17 00:00:00 2001 From: David Silva Date: Mon, 23 Dec 2019 23:54:54 +0000 Subject: [PATCH 1/7] feat(InviteFriendsEvent): filter message --- .../eu/habbo/messages/incoming/friends/InviteFriendsEvent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java index 185e2d47..a2624748 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java @@ -17,6 +17,8 @@ public class InviteFriendsEvent extends MessageHandler { String message = this.packet.readString(); + message = Emulator.getGameEnvironment().getWordFilter().filter(message, this.client.getHabbo()); + for (int i : userIds) { if (i == 0) continue; From c10a09357216b7ce8aec682e01dea9b03f27dabe Mon Sep 17 00:00:00 2001 From: David Silva Date: Tue, 24 Dec 2019 00:07:33 +0000 Subject: [PATCH 2/7] fix(RoomUnitEffects): add more effects to enum --- .../java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java index 5ae0885e..3be40d28 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java @@ -198,7 +198,11 @@ public enum RoomUnitEffect { WATERINGCAN(192), TRAMPOLINEJUMP(193), TREADMILL(194), - CROSSTRAINER(195); + CROSSTRAINER(195), + STARWARS(196), + FLYINGCARPET(197), + YELLOWDUCK(198), + FLYNGTURTLE(199); private int id; From 1151a6197de19a457b29e79514a7ef5257ec00ab Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 16:53:10 +0000 Subject: [PATCH 3/7] Teleporter Fix - Beny --- .../items/interactions/InteractionTeleport.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 0106e1b8..0720fba6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -21,7 +21,7 @@ public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; private int roomUnitID = -1; - private boolean walkable = false; + private boolean walkable; public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -82,6 +82,7 @@ public class InteractionTeleport extends HabboItem { if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { startTeleport(room, habbo); + walkable = true; } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { // set state 1 and walk on item this.roomUnitID = unit.getId(); @@ -93,11 +94,11 @@ public class InteractionTeleport extends HabboItem { List onFail = new ArrayList(); onSuccess.add(() -> { - walkable = this.getBaseItem().allowWalk(); room.updateTile(currentLocation); tryTeleport(client, room); unit.removeOverrideTile(currentLocation); unit.setCanLeaveRoomByDoor(true); + walkable = this.getBaseItem().allowWalk(); }); onFail.add(() -> { @@ -208,8 +209,10 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo, int delay) { - if (habbo.getRoomUnit().isTeleporting) + if (habbo.getRoomUnit().isTeleporting) { + walkable = this.getBaseItem().allowWalk(); return; + } this.roomUnitID = -1; habbo.getRoomUnit().isTeleporting = true; From cf5283c66f0b8dc83323337b7bdb010f7ac8369e Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 18:13:06 +0000 Subject: [PATCH 4/7] Vote Counters - By Beny --- .../habbo/habbohotel/items/ItemManager.java | 2 + .../interactions/InteractionVoteCounter.java | 106 ++++++++++++++++++ .../rooms/users/RoomUserSignEvent.java | 12 ++ 3 files changed, 120 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.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 ce313579..e0c533a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -355,6 +355,8 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("snowstorm_tree", null)); this.interactionsList.add(new ItemInteraction("snowstorm_machine", null)); this.interactionsList.add(new ItemInteraction("snowstorm_pile", null)); + + this.interactionsList.add(new ItemInteraction("vote_counter", InteractionVoteCounter.class)); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java new file mode 100644 index 00000000..54ea473b --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java @@ -0,0 +1,106 @@ +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.RoomUnit; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.wired.WiredEffectType; +import com.eu.habbo.messages.ServerMessage; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class InteractionVoteCounter extends HabboItem { + + private boolean frozen; + private int votes; + private List votedUsers; + + public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + if(!this.getExtradata().contains(",")) { + this.setExtradata("1,0"); // frozen,votes + } + + String[] bits = this.getExtradata().split(","); + frozen = bits[0].equals("1"); + votes = Integer.parseInt(bits[1]); + votedUsers = new ArrayList<>(); + } + + public InteractionVoteCounter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + + if(!extradata.contains(",")) { + extradata = "1,0"; + } + + String[] bits = extradata.split(","); + frozen = bits[0].equals("1"); + votes = Integer.parseInt(bits[1]); + votedUsers = new ArrayList<>(); + } + + @Override + public void serializeExtradata(ServerMessage serverMessage) { + serverMessage.appendInt((this.isLimited() ? 256 : 0) + 3); + serverMessage.appendString(this.frozen ? "0" : "1"); + serverMessage.appendInt(this.votes); + super.serializeExtradata(serverMessage); + } + + @Override + public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { + return false; + } + + @Override + public boolean isWalkable() { + return false; + } + + private void updateExtradata() { + this.setExtradata((this.frozen ? "1" : "0") + "," + this.votes); + } + + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType))) + return; + + this.frozen = !this.frozen; + + if(!frozen) { + this.votes = 0; + this.votedUsers.clear(); + } + + updateExtradata(); + this.needsUpdate(true); + room.updateItem(this); + } + + @Override + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + + } + + public void vote(Room room, int UserId, int vote) { + if(frozen) + return; + + if(votedUsers.contains(UserId)) + return; + + votedUsers.add(UserId); + + votes += vote; + updateExtradata(); + this.needsUpdate(true); + room.updateItem(this); + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java index 3e1200e6..3b2aaf93 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java @@ -1,8 +1,10 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionVoteCounter; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; +import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserSignEvent; @@ -20,6 +22,16 @@ public class RoomUserSignEvent extends MessageHandler { if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + ""); this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); + + if(signId <= 10) { + + int userId = this.client.getHabbo().getHabboInfo().getId(); + for (HabboItem item : room.getFloorItems()) { + if (item instanceof InteractionVoteCounter) { + ((InteractionVoteCounter)item).vote(room, userId, signId); + } + } + } } } } From aed6c495b4d4cf8c1f607411f7fced85590a6e1b Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 20:37:25 +0000 Subject: [PATCH 5/7] Effects now work properly in the clothing selector, as well as durations. Credits to Beny --- .../java/com/eu/habbo/core/CleanerThread.java | 4 +- .../items/interactions/InteractionFXBox.java | 37 +++++++++++++------ .../users/inventory/EffectsComponent.java | 11 ++++++ .../inventory/UserEffectsListComposer.java | 14 +++++-- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/eu/habbo/core/CleanerThread.java b/src/main/java/com/eu/habbo/core/CleanerThread.java index 9c174fca..764770d0 100644 --- a/src/main/java/com/eu/habbo/core/CleanerThread.java +++ b/src/main/java/com/eu/habbo/core/CleanerThread.java @@ -147,8 +147,8 @@ public class CleanerThread implements Runnable { statement.execute("DELETE users_favorite_rooms FROM users_favorite_rooms LEFT JOIN rooms ON room_id = rooms.id WHERE rooms.id IS NULL"); } - try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp < ? AND activation_timestamp != 0")) { - statement.setInt(1, Emulator.getIntUnixTimestamp() - 86400); + try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp + duration < ? AND activation_timestamp > 0 AND duration > 0")) { + statement.setInt(1, Emulator.getIntUnixTimestamp()); statement.execute(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java index f68a0aa8..3b579a54 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java @@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; +import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; @@ -15,41 +17,54 @@ import java.sql.SQLException; public class InteractionFXBox extends InteractionDefault { public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.setExtradata("0"); + // this.setExtradata("0"); } public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.setExtradata("0"); + // this.setExtradata("0"); } @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { super.onClick(client, room, objects); - if (client != null && room.hasRights(client.getHabbo())) { + if (client != null && this.getUserId() == client.getHabbo().getHabboInfo().getId()) { + if(this.getExtradata().equals("1")) + return; + + int effectId = -1; + if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) { if (this.getBaseItem().getEffectM() > 0) { - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); + effectId = this.getBaseItem().getEffectM(); } } if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) { if (this.getBaseItem().getEffectF() > 0) { - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + effectId = this.getBaseItem().getEffectF(); } } + if(effectId < 0) + return; + + if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) + return; + + EffectsComponent.HabboEffect effect = client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0); + client.sendResponse(new UserEffectsListComposer(client.getHabbo())); + client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId); + this.setExtradata("1"); room.updateItemState(this); room.removeHabboItem(this); HabboItem item = this; - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - new QueryDeleteHabboItem(item.getId()).run(); - room.sendComposer(new RemoveFloorItemComposer(item).compose()); - } + Emulator.getThreading().run(() -> { + new QueryDeleteHabboItem(item.getId()).run(); + room.sendComposer(new RemoveFloorItemComposer(item).compose()); + room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); }, 500); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 6be7b4dd..b0da325b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -34,6 +34,10 @@ public class EffectsComponent { } public HabboEffect createEffect(int effectId) { + return createEffect(effectId, 86400); + } + + public HabboEffect createEffect(int effectId, int duration) { HabboEffect effect; synchronized (this.effects) { if (this.effects.containsKey(effectId)) { @@ -44,6 +48,7 @@ public class EffectsComponent { } } else { effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId()); + effect.duration = duration; effect.insert(); } @@ -159,6 +164,9 @@ public class EffectsComponent { } public boolean isRemaining() { + if(this.duration <= 0) + return true; + if (this.total > 0) { if (this.activationTimestamp >= 0) { if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) { @@ -172,6 +180,9 @@ public class EffectsComponent { } public int remainingTime() { + if(this.duration <= 0) //permanant + return Integer.MAX_VALUE; + return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java index 9fa470af..157c53c9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java @@ -27,10 +27,16 @@ public class UserEffectsListComposer extends MessageComposer { this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> { UserEffectsListComposer.this.response.appendInt(effect.effect); UserEffectsListComposer.this.response.appendInt(0); - UserEffectsListComposer.this.response.appendInt(effect.duration); - UserEffectsListComposer.this.response.appendInt(effect.total); - UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1); - UserEffectsListComposer.this.response.appendBoolean(effect.isActivated()); + UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : 1); + UserEffectsListComposer.this.response.appendInt(effect.total - (effect.isActivated() ? 1 : 0)); + + if(!effect.isActivated()) { + UserEffectsListComposer.this.response.appendInt(0); + } + else { + UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? (Emulator.getIntUnixTimestamp() - effect.activationTimestamp) + effect.duration : -1); + } + UserEffectsListComposer.this.response.appendBoolean(effect.duration <= 0); //effect.isActivated()); return true; }); } From 4086127fba7687903e94c3416df232944a437336 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 20:40:13 +0000 Subject: [PATCH 6/7] RC-3 Completed. Ready for testing. --- src/main/java/com/eu/habbo/Emulator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 7b2cfa5d..bacb369a 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-2"; + public final static String PREVIEW = "RC-3"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -49,7 +49,7 @@ public final class Emulator { " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + " /____/ \n" + - " 'RC Stands for Race Car.' \n" ; + " 'The boiz are back in town.' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; @@ -136,7 +136,7 @@ public final class Emulator { Emulator.getThreading().run(() -> { - Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-1 Build. If you find any bugs please place them on our git repository."); + Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a 2.2.0 RC-3 Build. If you find any bugs please place them on our git repository."); Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: "); Emulator.getLogging().logStart("https://discord.gg/syuqgN"); Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); From 45e52f165b61f5ed238f2507ef1a26a95f925415 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 26 Dec 2019 20:43:04 +0000 Subject: [PATCH 7/7] Added SQL for vote counters. --- sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql index cbb9ce33..90e2028c 100644 --- a/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql +++ b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql @@ -1 +1,2 @@ -INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500'); \ No newline at end of file +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500'); +UPDATE items_base SET interaction_type = 'vote_counter' WHERE item_name = 'vote_count_add'; \ No newline at end of file