From d3aaca0300b4ac7cc2356705912759274c7d65b3 Mon Sep 17 00:00:00 2001 From: Dank074 Date: Sat, 18 Jan 2020 06:05:12 -0600 Subject: [PATCH 001/153] fixed WIRED Condition: Furni States and Positions Match bug --- src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index 5ac1bc7c..ec5960a8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -60,7 +60,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { this.y = set.getShort("y"); this.z = set.getDouble("z"); this.rotation = set.getInt("rot"); - this.extradata = set.getString("extra_data"); + this.extradata = set.getString("extra_data").isEmpty() ? "0" : set.getString("extra_data"); String ltdData = set.getString("limited_data"); if (!ltdData.isEmpty()) { @@ -79,7 +79,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { this.y = 0; this.z = 0; this.rotation = 0; - this.extradata = extradata; + this.extradata = extradata.isEmpty() ? "0" : extradata; this.limitedSells = limitedSells; this.limitedStack = limitedStack; } From edff4dbb53169dba7055aee978c0874f395b67c2 Mon Sep 17 00:00:00 2001 From: Dank074 Date: Sat, 18 Jan 2020 12:17:05 -0600 Subject: [PATCH 002/153] fixed classCastException in UpdateSTackHeightComposer --- .../messages/outgoing/rooms/UpdateStackHeightComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index 5a99f16c..e43084b1 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -29,7 +29,7 @@ public class UpdateStackHeightComposer extends MessageComposer { this.response.init(Outgoing.UpdateStackHeightComposer); if (this.updateTiles != null) { if(this.updateTiles.size() > 4) { - RoomTile[] tiles = (RoomTile[])this.updateTiles.toArray(); + RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); this.response.appendByte(4); for(int i = 0; i < 4; i++) { RoomTile t = tiles[i]; From 7e67052cac84c8ff67c20fc1b8240cecf045d0e0 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sun, 19 Jan 2020 22:56:14 +0000 Subject: [PATCH 003/153] Start 2.3.0 RC-1 --- 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 6392e58c..4ea10616 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -31,13 +31,13 @@ public final class Emulator { public final static int MAJOR = 2; - public final static int MINOR = 2; + public final static int MINOR = 3; - public final static int BUILD = 2; + public final static int BUILD = 0; - public final static String PREVIEW = "Stable"; + public final static String PREVIEW = "RC-1"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = From a3e5bcfa9f198b2018b546b2b455ed2b052b503a Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 19 Jan 2020 17:44:18 -0500 Subject: [PATCH 004/153] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cdb52090..6d9dd952 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/VERSION-2.2.0-success.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/VERSION-2.3.0RC1-success.svg?style=for-the-badge&logo=appveyor) ![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases From 78717fb175cc8807317b1f2fcfb79a1c4e069875 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 19 Jan 2020 17:44:29 -0500 Subject: [PATCH 005/153] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d9dd952..dc7bb020 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/VERSION-2.3.0RC1-success.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/VERSION-2.3.0-RC1-success.svg?style=for-the-badge&logo=appveyor) ![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases From cc48e56efabe8be1d04eee5640f8a61a62627c52 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 19 Jan 2020 17:44:37 -0500 Subject: [PATCH 006/153] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc7bb020..770837c9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/VERSION-2.3.0-RC1-success.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/VERSION-2.3.0 RC1-success.svg?style=for-the-badge&logo=appveyor) ![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases From 25f81e164f9712cb0f4ba4a7fef4aea66dcb6826 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sun, 19 Jan 2020 17:44:57 -0500 Subject: [PATCH 007/153] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 770837c9..0792d824 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt). ## Versions ## -![image](https://img.shields.io/badge/VERSION-2.3.0 RC1-success.svg?style=for-the-badge&logo=appveyor) +![image](https://img.shields.io/badge/VERSION-2.3.0-success.svg?style=for-the-badge&logo=appveyor) ![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor) Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases From ad96c6e74bfb4d9e961e408d534d52d75bce5b97 Mon Sep 17 00:00:00 2001 From: David Silva Date: Sun, 19 Jan 2020 18:18:15 -0500 Subject: [PATCH 008/153] Sanctions. Credits to zGrav (David Silva) --- .../eu/habbo/habbohotel/GameEnvironment.java | 7 + .../modtool/ModToolSanctionItem.java | 25 +++ .../modtool/ModToolSanctionLevelItem.java | 15 ++ .../habbohotel/modtool/ModToolSanctions.java | 174 ++++++++++++++++++ .../com/eu/habbo/messages/PacketManager.java | 2 + .../eu/habbo/messages/incoming/Incoming.java | 3 + .../incoming/handshake/SecureLoginEvent.java | 37 ++++ .../helper/MySanctionStatusEvent.java | 12 ++ .../modtool/ModToolSanctionAlertEvent.java | 26 ++- .../modtool/ModToolSanctionBanEvent.java | 26 ++- .../modtool/ModToolSanctionMuteEvent.java | 36 +++- .../ModToolSanctionTradeLockEvent.java | 27 ++- .../modtool/ModToolSanctionInfoComposer.java | 100 ++++++++-- .../events/sanctions/SanctionEvent.java | 17 ++ 14 files changed, 486 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java create mode 100644 src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index 02704bd3..93312b2c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.guilds.GuildManager; import com.eu.habbo.habbohotel.hotelview.HotelViewManager; import com.eu.habbo.habbohotel.items.ItemManager; import com.eu.habbo.habbohotel.modtool.ModToolManager; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.modtool.WordFilter; import com.eu.habbo.habbohotel.navigation.NavigatorManager; import com.eu.habbo.habbohotel.permissions.PermissionsManager; @@ -39,6 +40,7 @@ public class GameEnvironment { private PermissionsManager permissionsManager; private BotManager botManager; private ModToolManager modToolManager; + private ModToolSanctions modToolSanctions; private PetManager petManager; private AchievementManager achievementManager; private GuideManager guideManager; @@ -62,6 +64,7 @@ public class GameEnvironment { this.navigatorManager = new NavigatorManager(); this.commandHandler = new CommandHandler(); this.modToolManager = new ModToolManager(); + this.modToolSanctions = new ModToolSanctions(); this.achievementManager = new AchievementManager(); this.achievementManager.reload(); this.guideManager = new GuideManager(); @@ -145,6 +148,10 @@ public class GameEnvironment { return this.modToolManager; } + public ModToolSanctions getModToolSanctions() { + return this.modToolSanctions; + } + public PetManager getPetManager() { return this.petManager; } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java new file mode 100644 index 00000000..70d2b375 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionItem.java @@ -0,0 +1,25 @@ +package com.eu.habbo.habbohotel.modtool; + +public class ModToolSanctionItem { + public int id; + public int habboId; + public int sanctionLevel; + public int probationTimestamp; + public boolean isMuted; + public int muteDuration; + public int tradeLockedUntil; + public String reason; + + public ModToolSanctionItem(int id, int habboId, int sanctionLevel, int probationTimestamp, boolean isMuted, int muteDuration, int tradeLockedUntil, String reason) { + this.id = id; + this.habboId = habboId; + this.sanctionLevel = sanctionLevel; + this.probationTimestamp = probationTimestamp; + this.isMuted = isMuted; + this.muteDuration = muteDuration; + this.tradeLockedUntil = tradeLockedUntil; + this.reason = reason; + } + + +} diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java new file mode 100644 index 00000000..d893b4e2 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctionLevelItem.java @@ -0,0 +1,15 @@ +package com.eu.habbo.habbohotel.modtool; + +public class ModToolSanctionLevelItem { + public int sanctionLevel; + public String sanctionType; + public int sanctionHourLength; + public int sanctionProbationDays; + + public ModToolSanctionLevelItem(int sanctionLevel, String sanctionType, int sanctionHourLength, int sanctionProbationDays) { + this.sanctionLevel = sanctionLevel; + this.sanctionType = sanctionType; + this.sanctionHourLength = sanctionHourLength; + this.sanctionProbationDays = sanctionProbationDays; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java new file mode 100644 index 00000000..020f04f0 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -0,0 +1,174 @@ +package com.eu.habbo.habbohotel.modtool; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.plugin.events.sanctions.SanctionEvent; +import gnu.trove.map.hash.THashMap; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; + +public class ModToolSanctions { + + private final THashMap> sanctionHashmap; + private final THashMap sanctionLevelsHashmap; + + public ModToolSanctions() { + long millis = System.currentTimeMillis(); + this.sanctionHashmap = new THashMap<>(); + this.sanctionLevelsHashmap = new THashMap<>(); + this.loadModSanctions(); + Emulator.getLogging().logStart("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + + } + + public synchronized void loadModSanctions() { + this.sanctionHashmap.clear(); + this.sanctionLevelsHashmap.clear(); + + this.loadSanctionLevels(); + } + + private void loadSanctionLevels() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanction_levels")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + this.sanctionLevelsHashmap.put(set.getInt("level"), new ModToolSanctionLevelItem(set.getInt("level"), set.getString("type"), set.getInt("hour_length"), set.getInt("probation_days"))); + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public ModToolSanctionLevelItem getSanctionLevelItem(int sanctionLevel) { + return this.sanctionLevelsHashmap.get(sanctionLevel); + } + + public THashMap> getSanctions(int habboId) { + synchronized (this.sanctionHashmap) { + //this.sanctionHashmap.clear(); // TODO: unsure if needed at some point. + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanctions WHERE habbo_id = ? ORDER BY id ASC")) { + statement.setInt(1, habboId); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (this.sanctionHashmap.get(set.getInt("habbo_id")) == null) { + this.sanctionHashmap.put(set.getInt("habbo_id"), new ArrayList<>()); + } + + ModToolSanctionItem item = new ModToolSanctionItem(set.getInt("id"), set.getInt("habbo_id"), set.getInt("sanction_level"), set.getInt("probation_timestamp"), set.getBoolean("is_muted"), set.getInt("mute_duration"), set.getInt("trade_locked_until"), set.getString("reason")); + + if (!this.sanctionHashmap.get(set.getInt("habbo_id")).contains(item)) { + this.sanctionHashmap.get(set.getInt("habbo_id")).add(item); + } + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + + return this.sanctionHashmap; + } + } + + private void insertSanction(int habboId, int sanctionLevel, int probationTimestamp, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO sanctions (habbo_id, sanction_level, probation_timestamp, reason, trade_locked_until, is_muted, mute_duration) VALUES (?, ?, ?, ?, ?, ?, ?)")) { + statement.setInt(1, habboId); + statement.setInt(2, sanctionLevel); + statement.setInt(3, probationTimestamp); + statement.setString(4, reason); + statement.setInt(5, tradeLockedUntil); + statement.setBoolean(6, isMuted); + statement.setInt(7, muteDuration); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void updateSanction(int rowId, int sanctionLevel, int probationTimestamp) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET sanction_level = ? AND probation_timestamp = ? WHERE id = ?")) { + statement.setInt(1, sanctionLevel); + statement.setInt(2, probationTimestamp); + statement.setInt(3, rowId); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void updateTradeLockedUntil(int rowId, int tradeLockedUntil) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET trade_locked_until = ? WHERE id = ?")) { + statement.setInt(1, tradeLockedUntil); + statement.setInt(2, rowId); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void updateMuteDuration(int rowId, int muteDuration) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET muted_duration = ? WHERE id = ?")) { + statement.setInt(1, muteDuration); + statement.setInt(2, rowId); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public void run(int habboId, Habbo self, int sanctionLevel, int cfhTopic, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) { + sanctionLevel++; + + ModToolSanctionLevelItem sanctionLevelItem = getSanctionLevelItem(sanctionLevel); + + insertSanction(habboId, sanctionLevel, buildProbationTimestamp(sanctionLevelItem), reason, tradeLockedUntil, isMuted, muteDuration); + + runSanctionBasedOnLevel(sanctionLevelItem, habboId, reason, cfhTopic, self, muteDuration); + + Emulator.getPluginManager().fireEvent(new SanctionEvent(self, Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId), sanctionLevel)); + } + + private int buildProbationTimestamp(ModToolSanctionLevelItem sanctionLevelItem) { + return Emulator.getIntUnixTimestamp() + (sanctionLevelItem.sanctionProbationDays * 24 * 60 * 60); + } + + public int getProbationDays(ModToolSanctionLevelItem sanctionLevelItem) { + return sanctionLevelItem.sanctionProbationDays; + } + + private void runSanctionBasedOnLevel(ModToolSanctionLevelItem sanctionLevelItem, int habboId, String reason, int cfhTopic, Habbo self, int muteDuration) { + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId); + + int muteDurationSeconds = 0; + + if (muteDuration > 0) { + Date muteDurationDate = new Date((long) muteDuration * 1000); + long diff = muteDurationDate.getTime() - Emulator.getDate().getTime(); + muteDurationSeconds = Math.toIntExact(diff / 1000); + } + + switch (sanctionLevelItem.sanctionType) { + case "ALERT": habbo.alert(reason); break; + case "BAN": Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.sanctionHourLength, ModToolBanType.ACCOUNT, cfhTopic); break; + case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds); break; + default: break; + } + } + + public String getSanctionType(ModToolSanctionLevelItem sanctionLevelItem) { + return sanctionLevelItem.sanctionType; + } + + public int getTimeOfSanction(ModToolSanctionLevelItem sanctionLevelItem) { + return sanctionLevelItem.sanctionHourLength; + } +} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 7cda01db..8bd37ca8 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -31,6 +31,7 @@ import com.eu.habbo.messages.incoming.guides.*; import com.eu.habbo.messages.incoming.guilds.*; import com.eu.habbo.messages.incoming.guilds.forums.*; import com.eu.habbo.messages.incoming.handshake.*; +import com.eu.habbo.messages.incoming.helper.MySanctionStatusEvent; import com.eu.habbo.messages.incoming.helper.RequestTalentTrackEvent; import com.eu.habbo.messages.incoming.hotelview.*; import com.eu.habbo.messages.incoming.inventory.RequestInventoryBadgesEvent; @@ -561,6 +562,7 @@ public class PacketManager { this.registerHandler(Incoming.RequestResolutionEvent, RequestResolutionEvent.class); this.registerHandler(Incoming.RequestTalenTrackEvent, RequestTalentTrackEvent.class); this.registerHandler(Incoming.UnknownEvent1, UnknownEvent1.class); + this.registerHandler(Incoming.MySanctionStatusEvent, MySanctionStatusEvent.class); } void registerFloorPlanEditor() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 0b70e95b..87fb1494 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -216,6 +216,9 @@ public class Incoming { public static final int PostItRequestDataEvent = 3964; public static final int PostItSaveDataEvent = 3666; public static final int PostItDeleteEvent = 3336; + + public static final int MySanctionStatusEvent = 2746; + public static final int MoodLightSaveSettingsEvent = 1648; public static final int ModToolRequestIssueChatlogEvent = 211; public static final int ModToolRequestRoomUserChatlogEvent = -1; diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 28d985e7..9559fc7f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -2,6 +2,8 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; @@ -25,13 +27,17 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; import com.eu.habbo.messages.outgoing.modtool.CfhTopicsMessageComposer; import com.eu.habbo.messages.outgoing.modtool.ModToolComposer; +import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer; import com.eu.habbo.messages.outgoing.navigator.*; import com.eu.habbo.messages.outgoing.unknown.BuildersClubExpiredComposer; import com.eu.habbo.messages.outgoing.users.*; import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent; import com.eu.habbo.plugin.events.users.UserLoginEvent; +import gnu.trove.map.hash.THashMap; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; @NoAuthMessage public class SecureLoginEvent extends MessageHandler { @@ -135,6 +141,37 @@ public class SecureLoginEvent extends MessageHandler { this.client.sendResponse(new InventoryAchievementsComposer()); this.client.sendResponse(new AchievementListComposer(this.client.getHabbo())); + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + + + if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + + if (item.sanctionLevel > 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) { + this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo())); + } else if (item.sanctionLevel > 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateSanction(item.id, 0, 0); + } + + if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateTradeLockedUntil(item.id, 0); + habbo.getHabboStats().setAllowTrade(true); + } else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) { + habbo.getHabboStats().setAllowTrade(false); + } + + if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateMuteDuration(item.id, 0); + habbo.unMute(); + } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) { + Date muteDuration = new Date((long) item.muteDuration * 1000); + long diff = muteDuration.getTime() - Emulator.getDate().getTime(); + habbo.mute(Math.toIntExact(diff)); + } + } + Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress())); if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java b/src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java new file mode 100644 index 00000000..8608708f --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/helper/MySanctionStatusEvent.java @@ -0,0 +1,12 @@ +package com.eu.habbo.messages.incoming.helper; + +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer; + +public class MySanctionStatusEvent extends MessageHandler { + + @Override + public void handle() throws Exception { + this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo())); + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java index 26cfbda9..078808e0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java @@ -1,10 +1,18 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolBanType; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; +import gnu.trove.map.hash.THashMap; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; public class ModToolSanctionAlertEvent extends MessageHandler { @Override @@ -17,7 +25,23 @@ public class ModToolSanctionAlertEvent extends MessageHandler { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo != null) { - habbo.alert(message); + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + + if (item != null && item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + } + } else { + modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); + } + } else { + habbo.alert(message); + } } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java index f317c8d6..92940e79 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java @@ -2,9 +2,16 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolBanType; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; +import gnu.trove.map.hash.THashMap; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; public class ModToolSanctionBanEvent extends MessageHandler { public static final int BAN_18_HOURS = 3; @@ -42,7 +49,24 @@ public class ModToolSanctionBanEvent extends MessageHandler { duration = Emulator.getIntUnixTimestamp(); } if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { - Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic); + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId); + + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + + if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + } + } else { + modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); + } + } else { + Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic); + } + } else { ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ban").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java index f5664f93..aed5ca93 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java @@ -1,10 +1,20 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolBanType; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; +import gnu.trove.map.hash.THashMap; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; public class ModToolSanctionMuteEvent extends MessageHandler { @Override @@ -17,9 +27,29 @@ public class ModToolSanctionMuteEvent extends MessageHandler { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo != null) { - habbo.mute(60 * 60); - habbo.alert(message); - this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername())); + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + + if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); + + int muteDurationTimestamp = Math.toIntExact(new Date( System.currentTimeMillis() + (modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000); + + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp); + } + } else { + modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); + } + } else { + habbo.mute(60 * 60); + habbo.alert(message); + this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername())); + } } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java index ed8ad7af..c7c5a1c8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java @@ -1,10 +1,17 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer; +import gnu.trove.map.hash.THashMap; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; public class ModToolSanctionTradeLockEvent extends MessageHandler { @Override @@ -18,8 +25,24 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); if (habbo != null) { - habbo.getHabboStats().setAllowTrade(false); - habbo.alert(message); + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId); + + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + + if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); + } + } else { + modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, duration, false, 0); + } + } else { + habbo.getHabboStats().setAllowTrade(false); + habbo.alert(message); + } } else { this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index 3e24b6a8..5acfeaf3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -1,26 +1,98 @@ package com.eu.habbo.messages.outgoing.modtool; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; +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 gnu.trove.map.hash.THashMap; +import org.joda.time.DateTime; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; public class ModToolSanctionInfoComposer extends MessageComposer { + + private final Habbo habbo; + + public ModToolSanctionInfoComposer(Habbo habbo) { + this.habbo = habbo; + } + @Override public ServerMessage compose() { - this.response.init(Outgoing.ModToolSanctionInfoComposer); - this.response.appendBoolean(false); //Has Last Sanction. - this.response.appendBoolean(false); //Is probabtion. - this.response.appendString("<< Last Sanction >>"); - this.response.appendInt(0); //Value | Probation days left. - this.response.appendInt(-1); //Unused - this.response.appendString("<< Reason >>"); //Reason - this.response.appendString("1/1/1970 00:00"); //Start Time - this.response.appendInt(0); //Probation Days Left - this.response.appendString("<< Next Sanction >>"); //Next Sanction - this.response.appendInt(0); //Value - this.response.appendInt(-1); //Unused - this.response.appendBoolean(false); //Trade Locked - this.response.appendString("1/1/1970 00:00"); //Trade Locked Untill + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + + Date probationEndTime; + Date probationStartTime = null; + long numberOfDaysProbation = 0; + long numberOfHoursProbation = 0; + + if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + + boolean prevItem = modToolSanctionItems.size() > 1; + + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); + ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1); + + if (item.probationTimestamp > 0) { + probationEndTime = new Date((long) item.probationTimestamp * 1000); + long diff = probationEndTime.getTime() - Emulator.getDate().getTime(); + numberOfDaysProbation = diff / 1000 / 60 / 60 / 24; + numberOfHoursProbation = diff / 1000 / 60 / 60; + + probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); + + } + + Date tradeLockedUntil = null; + + if (item.tradeLockedUntil > 0) { + tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000); + } + + this.response.init(Outgoing.ModToolSanctionInfoComposer); + + this.response.appendBoolean(prevItem); // has prev sanction + this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation + this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type + this.response.appendInt(Math.toIntExact(numberOfDaysProbation)); // probation days left + this.response.appendInt(30); // unused? + this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason + this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time + this.response.appendInt(Math.toIntExact(numberOfHoursProbation)); // days of probation in hours? + this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type + this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) + this.response.appendInt(30); // unused? + this.response.appendBoolean(item.isMuted); // muted + this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until + + } else { + this.response.init(Outgoing.ModToolSanctionInfoComposer); + + this.response.appendBoolean(false); // has prev sanction + this.response.appendBoolean(false); // is on probation + this.response.appendString("ALERT"); // last sanction type + this.response.appendInt(0); // probation days left + this.response.appendInt(30); // unused? + this.response.appendString("cfh.reason.EMPTY"); // reason + this.response.appendString(Emulator.getDate().toString()); // probation start time + this.response.appendInt(0); // days of probation in hours? + this.response.appendString("ALERT"); // next sanction type + this.response.appendInt(0); // time to be applied in next sanction (in hours) + this.response.appendInt(30); // unused? + this.response.appendBoolean(false); // muted + this.response.appendString(""); // trade locked until + + } + return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java b/src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java new file mode 100644 index 00000000..1a73c4f0 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/sanctions/SanctionEvent.java @@ -0,0 +1,17 @@ +package com.eu.habbo.plugin.events.sanctions; + +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.plugin.events.support.SupportEvent; + +public class SanctionEvent extends SupportEvent { + public Habbo target; + + public int sanctionLevel; + + public SanctionEvent(Habbo moderator, Habbo target, int sanctionLevel) { + super(moderator); + + this.target = target; + this.sanctionLevel = sanctionLevel; + } +} From ff22fe2c70f0595c1f10ba8b383250ef5d805c84 Mon Sep 17 00:00:00 2001 From: David Silva Date: Mon, 20 Jan 2020 00:33:56 +0100 Subject: [PATCH 009/153] feat(sqlupdates): push sanction sql --- sqlupdates/2_2_2_TO_2_3_0.sql | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sqlupdates/2_2_2_TO_2_3_0.sql diff --git a/sqlupdates/2_2_2_TO_2_3_0.sql b/sqlupdates/2_2_2_TO_2_3_0.sql new file mode 100644 index 00000000..8df3c1b5 --- /dev/null +++ b/sqlupdates/2_2_2_TO_2_3_0.sql @@ -0,0 +1,32 @@ +CREATE TABLE `sanctions` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `habbo_id` int(11) NOT NULL DEFAULT '0', + `sanction_level` int(11) NOT NULL DEFAULT '0', + `probation_timestamp` int(32) NOT NULL DEFAULT '0', + `reason` varchar(255) NOT NULL DEFAULT '', + `trade_locked_until` int(32) NOT NULL DEFAULT '0', + `is_muted` tinyint(1) NOT NULL DEFAULT '0', + `mute_duration` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `sanction_levels` ( + `level` int(1) NOT NULL, + `type` enum('ALERT', 'BAN', 'MUTE') NOT NULL, + `hour_length` int(12) NOT NULL, + `probation_days` int(12) NOT NULL, + PRIMARY KEY (`level`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +ALTER TABLE `sanction_levels` +ADD CONSTRAINT `level` CHECK (`level`<=7); + +INSERT INTO `sanction_levels` VALUES (1, 'ALERT', 0, 30); +INSERT INTO `sanction_levels` VALUES (2, 'MUTE', 1, 30); +INSERT INTO `sanction_levels` VALUES (3, 'BAN', 18, 30); +INSERT INTO `sanction_levels` VALUES (4, 'BAN', 168, 30); +INSERT INTO `sanction_levels` VALUES (5, 'BAN', 720, 60); +INSERT INTO `sanction_levels` VALUES (6, 'BAN', 720, 60); +INSERT INTO `sanction_levels` VALUES (7, 'BAN', 876581, 876581); + +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.sanctions.enabled', '1'); From 8d6010fde3c5d603238e1bc334489053d498c14f Mon Sep 17 00:00:00 2001 From: skeletor Date: Sun, 19 Jan 2020 20:42:51 -0500 Subject: [PATCH 010/153] added remaining NumberFormatExceptions in totem interactions to try/catch block --- .../items/interactions/totems/InteractionTotemHead.java | 7 ++++++- .../items/interactions/totems/InteractionTotemLegs.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java index b0e63eb8..aa9dcb62 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java @@ -35,7 +35,12 @@ public class InteractionTotemHead extends InteractionDefault { } public TotemColor getTotemColor() { - int extraData = Integer.parseInt(this.getExtradata()); + int extraData; + try { + extraData = Integer.parseInt(this.getExtradata()); + }catch(NumberFormatException ex) { + extraData = 0; + } if(extraData < 3) { return TotemColor.NONE; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java index 4555a2f9..d8d83da4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java @@ -31,7 +31,12 @@ public class InteractionTotemLegs extends InteractionDefault { } public TotemColor getTotemColor() { - int extraData = Integer.parseInt(this.getExtradata()); + int extraData; + try { + extraData = Integer.parseInt(this.getExtradata()); + } catch(NumberFormatException ex) { + extraData = 0; + } return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1))); } From 3fb3b200d21311b9fd8b8e2756f6838706c6b526 Mon Sep 17 00:00:00 2001 From: skeletor Date: Tue, 21 Jan 2020 06:26:44 -0500 Subject: [PATCH 011/153] fixed byte-overflow in UpdateStackHeightComposer --- .../com/eu/habbo/habbohotel/rooms/Room.java | 4 ++-- .../rooms/items/SetStackHelperHeightEvent.java | 2 +- .../rooms/UpdateStackHeightComposer.java | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 174cad24..480f5f4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -547,7 +547,7 @@ public class Room implements Comparable, ISerialize, Runnable { tile.setState(this.calculateTileState(tile)); } - this.sendComposer(new UpdateStackHeightComposer(tiles).compose()); + this.sendComposer(new UpdateStackHeightComposer(this, tiles).compose()); } private RoomTileState calculateTileState(RoomTile tile) { @@ -655,7 +655,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } - this.sendComposer(new UpdateStackHeightComposer(updatedTiles).compose()); + this.sendComposer(new UpdateStackHeightComposer(this, updatedTiles).compose()); this.updateTiles(updatedTiles); for (RoomTile tile : updatedTiles) { this.updateHabbosAt(tile.x, tile.y); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java index 4986e685..a46bb7d2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetStackHelperHeightEvent.java @@ -51,7 +51,7 @@ public class SetStackHelperHeightEvent extends MessageHandler { item.needsUpdate(true); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item); this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles); - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tiles).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(room, tiles).compose()); this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightTileHeightComposer(item, (int) ((height) * 100)).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index e43084b1..b01a6369 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -1,5 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -12,6 +13,7 @@ public class UpdateStackHeightComposer extends MessageComposer { private double height; private THashSet updateTiles; + private Room room; public UpdateStackHeightComposer(int x, int y, double height) { this.x = x; @@ -19,24 +21,29 @@ public class UpdateStackHeightComposer extends MessageComposer { this.height = height; } - public UpdateStackHeightComposer(THashSet updateTiles) { + public UpdateStackHeightComposer(Room room, THashSet updateTiles) { this.updateTiles = updateTiles; + this.room = room; } @Override public ServerMessage compose() { - //TODO: THIS IS A TEMP FIX. THERE IS AN ISSUE WITH BAD PACKET STRUCTURE HERE CAUSING ISSUES WITH MOVING LARGE FURNITURE + //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done this.response.init(Outgoing.UpdateStackHeightComposer); if (this.updateTiles != null) { - if(this.updateTiles.size() > 4) { + // prevent overflow. Byte max value is 127 + if(this.updateTiles.size() > 127) { RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); - this.response.appendByte(4); - for(int i = 0; i < 4; i++) { + this.response.appendByte(127); + for(int i = 0; i < 127; i++) { RoomTile t = tiles[i]; + updateTiles.remove(t); // remove it from the set this.response.appendByte((int) t.x); this.response.appendByte((int) t.y); this.response.appendShort(t.relativeHeight()); } + //send the remaining tiles in a new message + this.room.sendComposer(new UpdateStackHeightComposer(this.room, updateTiles).compose()); return this.response; } From 3bc368277115436d3e693f5331eba01d45f41c33 Mon Sep 17 00:00:00 2001 From: David Silva Date: Tue, 21 Jan 2020 15:22:19 +0100 Subject: [PATCH 012/153] fix(ModToolSanctionInfoComposer): small patch regarding time --- .../modtool/ModToolSanctionInfoComposer.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index 5acfeaf3..b90266d0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -31,8 +31,6 @@ public class ModToolSanctionInfoComposer extends MessageComposer { Date probationEndTime; Date probationStartTime = null; - long numberOfDaysProbation = 0; - long numberOfHoursProbation = 0; if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); @@ -44,9 +42,6 @@ public class ModToolSanctionInfoComposer extends MessageComposer { if (item.probationTimestamp > 0) { probationEndTime = new Date((long) item.probationTimestamp * 1000); - long diff = probationEndTime.getTime() - Emulator.getDate().getTime(); - numberOfDaysProbation = diff / 1000 / 60 / 60 / 24; - numberOfHoursProbation = diff / 1000 / 60 / 60; probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); @@ -63,11 +58,11 @@ public class ModToolSanctionInfoComposer extends MessageComposer { this.response.appendBoolean(prevItem); // has prev sanction this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type - this.response.appendInt(Math.toIntExact(numberOfDaysProbation)); // probation days left + this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction this.response.appendInt(30); // unused? this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time - this.response.appendInt(Math.toIntExact(numberOfHoursProbation)); // days of probation in hours? + this.response.appendInt(0); // unused? this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) this.response.appendInt(30); // unused? @@ -80,11 +75,11 @@ public class ModToolSanctionInfoComposer extends MessageComposer { this.response.appendBoolean(false); // has prev sanction this.response.appendBoolean(false); // is on probation this.response.appendString("ALERT"); // last sanction type - this.response.appendInt(0); // probation days left + this.response.appendInt(0); // time of current sanction this.response.appendInt(30); // unused? this.response.appendString("cfh.reason.EMPTY"); // reason this.response.appendString(Emulator.getDate().toString()); // probation start time - this.response.appendInt(0); // days of probation in hours? + this.response.appendInt(0); // unused? this.response.appendString("ALERT"); // next sanction type this.response.appendInt(0); // time to be applied in next sanction (in hours) this.response.appendInt(30); // unused? From f1e3a3126a102ea46be4f38a19ede92307ccf446 Mon Sep 17 00:00:00 2001 From: David Silva Date: Tue, 21 Jan 2020 09:25:55 -0500 Subject: [PATCH 013/153] Update ModToolSanctionInfoComposer.java --- .../modtool/ModToolSanctionInfoComposer.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index b90266d0..288d2ff9 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -59,13 +59,13 @@ public class ModToolSanctionInfoComposer extends MessageComposer { this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction - this.response.appendInt(30); // unused? + this.response.appendInt(30); // TODO: unused? this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time - this.response.appendInt(0); // unused? + this.response.appendInt(0); // TODO: unused? this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) - this.response.appendInt(30); // unused? + this.response.appendInt(30); // TODO: unused? this.response.appendBoolean(item.isMuted); // muted this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until @@ -76,13 +76,13 @@ public class ModToolSanctionInfoComposer extends MessageComposer { this.response.appendBoolean(false); // is on probation this.response.appendString("ALERT"); // last sanction type this.response.appendInt(0); // time of current sanction - this.response.appendInt(30); // unused? + this.response.appendInt(30); // TODO: unused? this.response.appendString("cfh.reason.EMPTY"); // reason this.response.appendString(Emulator.getDate().toString()); // probation start time - this.response.appendInt(0); // unused? + this.response.appendInt(0); // TODO: unused? this.response.appendString("ALERT"); // next sanction type this.response.appendInt(0); // time to be applied in next sanction (in hours) - this.response.appendInt(30); // unused? + this.response.appendInt(30); // TODO: unused? this.response.appendBoolean(false); // muted this.response.appendString(""); // trade locked until From 4a3e59557d21a789f152537c891fdd053f4bf112 Mon Sep 17 00:00:00 2001 From: skeletor Date: Tue, 21 Jan 2020 15:18:30 -0500 Subject: [PATCH 014/153] Wired Reset Timers Effect should also reset Wired Trigger Periodically and Wired Trigger Periodically Long --- src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java | 3 ++- 1 file changed, 2 insertions(+), 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 ac1b2cc7..50232b1c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -419,7 +419,8 @@ public class WiredHandler { return; THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.AT_GIVEN_TIME); - + triggers.addAll(room.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY)); + triggers.addAll(room.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY_LONG)); if (triggers != null) { for (InteractionWiredTrigger trigger : triggers) { ((WiredTriggerReset) trigger).resetTimer(); From f7957a82d0dc821544942dce34472a51e3d2f5be Mon Sep 17 00:00:00 2001 From: skeletor Date: Tue, 21 Jan 2020 15:22:53 -0500 Subject: [PATCH 015/153] [patch] Fixed move-and-rotate wired should not allow movement into allow-sit furni --- .../wired/effects/WiredEffectMoveRotateFurni.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index caabe0e0..c261c851 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -69,7 +69,6 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { rotationToAdd = 6; } } - } int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); @@ -162,7 +161,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { RoomTile tile = layout.getTile(x, y); - if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) { + if (tile == null || tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED || !tile.getAllowStack()) { validMove = false; break; } @@ -181,9 +180,13 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { } HabboItem i = room.getTopItemAt(x, y, item); - if (i == null || i == item || i.getBaseItem().allowStack()) { - offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); + if (i != null && !i.getBaseItem().allowStack()) { + validMove = false; + break; } + + offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); + tilesToUpdate.add(tile); } } From e108796ad1dfc2a550052c1cc32801f6ea38153f Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 21 Jan 2020 23:35:33 +0000 Subject: [PATCH 016/153] Fixed colors on Windows using Jansi. New Loading sequence. --- pom.xml | 24 +++++++++++-- src/main/java/com/eu/habbo/Emulator.java | 45 +++++++++++++----------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index 557fc959..5fa89a3e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.eu.habbo Habbo - 2.2.2 + 2.3.0 UTF-8 @@ -79,7 +79,11 @@ central - http://repo1.maven.org/maven2/ + https://repo1.maven.org/maven2/ + + + mvnrepo + https://mvnrepository.com/ @@ -91,6 +95,14 @@ 4.1.36.Final + + + org.fusesource.jansi + jansi + 1.18 + + + io.netty netty-codec-http @@ -182,4 +194,12 @@ + + + + internal.repo + Internal repo + file:///home/thara/testesb/in + + \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 4ea10616..e82431ca 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -17,6 +17,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent; import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent; import com.eu.habbo.threading.ThreadPooling; import com.eu.habbo.util.imager.badges.BadgeImager; +import org.fusesource.jansi.AnsiConsole; import java.io.*; import java.security.MessageDigest; @@ -28,27 +29,30 @@ import java.util.Random; public final class Emulator { + public final static int MAJOR = 2; - - public final static int MINOR = 3; - - public final static int BUILD = 0; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_WHITE = "\u001B[37m"; + public static final String ANSI_YELLOW = "\u001B[33m"; public final static String PREVIEW = "RC-1"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = + "\n" + + "███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗ \n" + + "████╗ ████║██╔═══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗\n" + + "██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" + + "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" + + "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" + + "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" + + " "; - " \n" + - " __ ___ _ A R C T U R U S __ \n" + - " / |/ /___ _________ (_)___ ____ ______/ /_____ ______ \n" + - " / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" + - " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + - "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + - " /____/ \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; @@ -81,14 +85,18 @@ public final class Emulator { public static void main(String[] args) throws Exception { try { + AnsiConsole.systemInstall(); Locale.setDefault(new Locale("en")); - setBuild(); Emulator.stopped = false; ConsoleCommand.load(); Emulator.logging = new Logging(); - Emulator.getLogging().logStart("\r" + Emulator.logo + - " Build: " + build + "\n"); + System.out.println(ANSI_PURPLE + logo ); + System.out.println(ANSI_WHITE + "This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); + System.out.println(ANSI_BLUE + "[VERSION] " + ANSI_WHITE + version); + System.out.println(ANSI_RED + "[BUILD] " + ANSI_WHITE + build + "\n"); + System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq" ); + System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Join our discord at https://discord.gg/syuqgN" + "\n"); random = new Random(); long startTime = System.nanoTime(); @@ -119,7 +127,6 @@ public final class Emulator { Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB"); Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode"); - if (debugging) { Emulator.getLogging().logDebugLine("Debugging Enabled!"); } @@ -134,10 +141,6 @@ public final class Emulator { Emulator.getThreading().run(() -> { - 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."); - System.out.println("Waiting for commands: "); }, 1500); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); @@ -189,6 +192,7 @@ public final class Emulator { } private static void dispose() { + Emulator.getThreading().setCanAdd(false); Emulator.isShuttingDown = true; Emulator.isReady = false; @@ -245,16 +249,17 @@ public final class Emulator { Emulator.gameServer.stop(); } catch (Exception e) { } - Emulator.getLogging().logShutdownLine("Stopped Arcturus Emulator " + version + "..."); if (Emulator.database != null) { Emulator.getDatabase().dispose(); } Emulator.stopped = true; + AnsiConsole.systemUninstall(); try { if (Emulator.threading != null) + Emulator.threading.shutDown(); } catch (Exception e) { } From b8548495398075fd1bc7748bb0e0db107b5d21f1 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 22 Jan 2020 00:03:24 +0000 Subject: [PATCH 017/153] Fixed typo in ModToolSanctions.java --- .../java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java index 020f04f0..ca72f787 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -115,7 +115,7 @@ public class ModToolSanctions { } public void updateMuteDuration(int rowId, int muteDuration) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET muted_duration = ? WHERE id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET mute_duration = ? WHERE id = ?")) { statement.setInt(1, muteDuration); statement.setInt(2, rowId); From b80ebad61bd438144a73623a14b1e27b0e052385 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 22 Jan 2020 11:17:04 +0200 Subject: [PATCH 018/153] Fix unidles trigger --- .../interactions/wired/triggers/WiredTriggerHabboUnidle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java index 2ed298fb..e058b1e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java @@ -14,7 +14,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WiredTriggerHabboUnidle extends InteractionWiredTrigger { - private static final WiredTriggerType type = WiredTriggerType.IDLES; + private static final WiredTriggerType type = WiredTriggerType.UNIDLES; public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); From d6a21ed1318895d52d6e5ce39be670eb21385c6e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 22 Jan 2020 11:24:29 +0200 Subject: [PATCH 019/153] Do not pick up postit notes with pickall --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 480f5f4c..a99a9ea6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4089,11 +4089,10 @@ public class Room implements Comparable, ISerialize, Runnable { if (habbo != null && iterator.value().getUserId() == habbo.getHabboInfo().getId()) continue; - if (userItemsMap.get(iterator.value().getUserId()) == null) { - userItemsMap.put(iterator.value().getUserId(), new THashSet<>()); - } + if (iterator.value() instanceof InteractionPostIt) + continue; - userItemsMap.get(iterator.value().getUserId()).add(iterator.value()); + userItemsMap.computeIfAbsent(iterator.value().getUserId(), k -> new THashSet<>()).add(iterator.value()); } } From 30490af9d2829e2cb8a66d6cccd8927351fe62b1 Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 22 Jan 2020 04:32:11 -0500 Subject: [PATCH 020/153] fixed null pointer exception in timer reset wired --- .../wired/triggers/WiredTriggerRepeater.java | 15 ++++++++++++++- .../wired/triggers/WiredTriggerRepeaterLong.java | 15 ++++++++++++++- .../eu/habbo/habbohotel/wired/WiredHandler.java | 11 ++++------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index 4476c515..d7fd07b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -1,9 +1,11 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -17,7 +19,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable { +public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY; public static final int DEFAULT_DELAY = 20 * 500; @@ -123,4 +125,15 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } } } + + @Override + public void resetTimer() { + this.counter = 0; + if (this.getRoomId() != 0) { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + if (room != null && room.isLoaded()) { + WiredHandler.handle(this, null, room, new Object[]{this}); + } + } + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 5a0df5a1..7020988e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -1,9 +1,11 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -17,7 +19,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable { +public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { public static final int DEFAULT_DELAY = 20 * 5000; private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG; private int repeatTime = DEFAULT_DELAY; @@ -117,4 +119,15 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } } } + + @Override + public void resetTimer() { + this.counter = 0; + if (this.getRoomId() != 0) { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + if (room != null && room.isLoaded()) { + WiredHandler.handle(this, null, room, new Object[]{this}); + } + } + } } 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 50232b1c..aa600682 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -418,14 +418,11 @@ public class WiredHandler { if (!room.isLoaded()) return; - THashSet triggers = room.getRoomSpecialTypes().getTriggers(WiredTriggerType.AT_GIVEN_TIME); - triggers.addAll(room.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY)); - triggers.addAll(room.getRoomSpecialTypes().getTriggers(WiredTriggerType.PERIODICALLY_LONG)); - if (triggers != null) { - for (InteractionWiredTrigger trigger : triggers) { - ((WiredTriggerReset) trigger).resetTimer(); + room.getRoomSpecialTypes().getTriggers().forEach(t-> { + if(t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG) { + ((WiredTriggerReset) t).resetTimer(); } - } + }); room.setLastTimerReset(Emulator.getIntUnixTimestamp()); } From 944745e7d8270d1934f2760cb8cedad880773c60 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 22 Jan 2020 11:56:27 +0200 Subject: [PATCH 021/153] Tweak roller glitch to fix #107 --- .../messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 9f30152a..0b14605e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -65,7 +65,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { RoomUnitOnRollerComposer.this.roomUnit.setZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight()); RoomUnitOnRollerComposer.this.roomUnit.sitUpdate = true; } - }, this.room.getRollerSpeed() == 0 ? 250 : 500); + }, this.room.getRollerSpeed() == 0 ? 250 : 400); } else { this.roomUnit.setLocation(this.newLocation); this.roomUnit.setZ(this.newZ); From 4360507fa819b670fcfe2ae4d6faceede6c31ca6 Mon Sep 17 00:00:00 2001 From: David Silva Date: Wed, 22 Jan 2020 16:15:44 +0100 Subject: [PATCH 022/153] feat(ModToolUserInfoComposer): display last sanction + small improv. --- .../incoming/handshake/SecureLoginEvent.java | 46 +++++++------ .../modtool/ModToolSanctionAlertEvent.java | 5 +- .../modtool/ModToolSanctionBanEvent.java | 5 +- .../modtool/ModToolSanctionMuteEvent.java | 5 +- .../ModToolSanctionTradeLockEvent.java | 5 +- .../modtool/ModToolSanctionInfoComposer.java | 69 ++++++++++--------- .../modtool/ModToolUserInfoComposer.java | 25 +++++-- 7 files changed, 93 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 9559fc7f..d579482c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -142,33 +142,35 @@ public class SecureLoginEvent extends MessageHandler { this.client.sendResponse(new AchievementListComposer(this.client.getHabbo())); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); - if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { - ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - if (item.sanctionLevel > 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) { - this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo())); - } else if (item.sanctionLevel > 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateSanction(item.id, 0, 0); - } + if (item.sanctionLevel > 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) { + this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo())); + } else if (item.sanctionLevel > 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateSanction(item.id, 0, 0); + } - if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateTradeLockedUntil(item.id, 0); - habbo.getHabboStats().setAllowTrade(true); - } else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) { - habbo.getHabboStats().setAllowTrade(false); - } + if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateTradeLockedUntil(item.id, 0); + habbo.getHabboStats().setAllowTrade(true); + } else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) { + habbo.getHabboStats().setAllowTrade(false); + } - if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateMuteDuration(item.id, 0); - habbo.unMute(); - } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) { - Date muteDuration = new Date((long) item.muteDuration * 1000); - long diff = muteDuration.getTime() - Emulator.getDate().getTime(); - habbo.mute(Math.toIntExact(diff)); + if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateMuteDuration(item.id, 0); + habbo.unMute(); + } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) { + Date muteDuration = new Date((long) item.muteDuration * 1000); + long diff = muteDuration.getTime() - Emulator.getDate().getTime(); + habbo.mute(Math.toIntExact(diff)); + } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java index 078808e0..98e27cc6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java @@ -26,10 +26,11 @@ public class ModToolSanctionAlertEvent extends MessageHandler { if (habbo != null) { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java index 92940e79..59e05e89 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java @@ -50,10 +50,11 @@ public class ModToolSanctionBanEvent extends MessageHandler { } if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId); if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId); + if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java index aed5ca93..b7451cfe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java @@ -28,10 +28,11 @@ public class ModToolSanctionMuteEvent extends MessageHandler { if (habbo != null) { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java index c7c5a1c8..1969da0f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java @@ -26,10 +26,11 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler { if (habbo != null) { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId); if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(userId); + if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index 288d2ff9..e6b87afc 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -26,49 +26,52 @@ public class ModToolSanctionInfoComposer extends MessageComposer { @Override public ServerMessage compose() { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); Date probationEndTime; Date probationStartTime = null; - if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { - ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); - boolean prevItem = modToolSanctionItems.size() > 1; + if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); - ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1); + boolean prevItem = modToolSanctionItems.size() > 1; - if (item.probationTimestamp > 0) { - probationEndTime = new Date((long) item.probationTimestamp * 1000); + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); + ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1); - probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); + if (item.probationTimestamp > 0) { + probationEndTime = new Date((long) item.probationTimestamp * 1000); + + probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); + + } + + Date tradeLockedUntil = null; + + if (item.tradeLockedUntil > 0) { + tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000); + } + + this.response.init(Outgoing.ModToolSanctionInfoComposer); + + this.response.appendBoolean(prevItem); // has prev sanction + this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation + this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type + this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction + this.response.appendInt(30); // TODO: unused? + this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason + this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time + this.response.appendInt(0); // TODO: unused? + this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type + this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) + this.response.appendInt(30); // TODO: unused? + this.response.appendBoolean(item.isMuted); // muted + this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until } - - Date tradeLockedUntil = null; - - if (item.tradeLockedUntil > 0) { - tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000); - } - - this.response.init(Outgoing.ModToolSanctionInfoComposer); - - this.response.appendBoolean(prevItem); // has prev sanction - this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation - this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type - this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction - this.response.appendInt(30); // TODO: unused? - this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason - this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time - this.response.appendInt(0); // TODO: unused? - this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type - this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) - this.response.appendInt(30); // TODO: unused? - this.response.appendBoolean(item.isMuted); // muted - this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until - } else { this.response.init(Outgoing.ModToolSanctionInfoComposer); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java index 804ec6e1..59723fdb 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java @@ -1,12 +1,17 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem; +import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import gnu.trove.map.hash.THashMap; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; public class ModToolUserInfoComposer extends MessageComposer { private final ResultSet set; @@ -37,11 +42,23 @@ public class ModToolUserInfoComposer extends MessageComposer { this.response.appendString(this.set.getString("mail")); this.response.appendString("Rank (" + this.set.getInt("rank_id") + "): " + this.set.getString("rank_name")); //user_class_txt - if (false) //has sanction - { - this.response.appendString("SOME SANCTION"); - this.response.appendInt(31); + ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); + + if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(this.set.getInt("user_id")); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(this.set.getInt("user_id")); + + if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) //has sanction + { + ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); + + this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); + this.response.appendInt(31); + } + } + return this.response; } catch (SQLException e) { Emulator.getLogging().logSQLException(e); From 66f047bb5333d28c9d4645758e685800280059b1 Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 22 Jan 2020 10:22:05 -0500 Subject: [PATCH 023/153] [patch] wired effect move rotate should allow rotation of furniture occupied by users/bots/pets --- .../wired/effects/WiredEffectMoveRotateFurni.java | 9 +++++++-- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index c261c851..c83fcad7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -72,15 +72,20 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { } int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); - //Verify if rotation result in a valid position - if (rotationToAdd > 0 && room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation).equals(FurnitureMovementError.NONE))//room.canPlaceFurnitureAt(item, null, room.getLayout().getTile(item.getX(), item.getY()), item.getRotation() + rotationToAdd)) + FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); + if (rotationToAdd > 0 && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || + rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) { item.setRotation(newRotation); if (this.direction == 0) { tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); room.sendComposer(new FloorItemUpdateComposer(item).compose()); + for (RoomTile t : tilesToUpdate) { + room.updateHabbosAt(t.x, t.y); + room.updateBotsAt(t.x, t.y); + } } } 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 a99a9ea6..e88598a7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -751,7 +751,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - private void updateBotsAt(short x, short y) { + public void updateBotsAt(short x, short y) { HabboItem topItem = this.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); From 8be461354cefafd1613841862c698f94a208aac4 Mon Sep 17 00:00:00 2001 From: David Silva Date: Wed, 22 Jan 2020 17:07:24 +0100 Subject: [PATCH 024/153] fix(sanctions): check if sanctions are active/ignore level 0's --- .../habbohotel/modtool/ModToolSanctions.java | 11 +-- .../incoming/handshake/SecureLoginEvent.java | 6 +- .../modtool/ModToolSanctionInfoComposer.java | 91 ++++++++++--------- 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java index ca72f787..91ad713b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -51,7 +51,7 @@ public class ModToolSanctions { public THashMap> getSanctions(int habboId) { synchronized (this.sanctionHashmap) { - //this.sanctionHashmap.clear(); // TODO: unsure if needed at some point. + this.sanctionHashmap.clear(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanctions WHERE habbo_id = ? ORDER BY id ASC")) { statement.setInt(1, habboId); try (ResultSet set = statement.executeQuery()) { @@ -91,11 +91,10 @@ public class ModToolSanctions { } } - public void updateSanction(int rowId, int sanctionLevel, int probationTimestamp) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET sanction_level = ? AND probation_timestamp = ? WHERE id = ?")) { - statement.setInt(1, sanctionLevel); - statement.setInt(2, probationTimestamp); - statement.setInt(3, rowId); + public void updateSanction(int rowId, int probationTimestamp) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET probation_timestamp = ? WHERE id = ?")) { + statement.setInt(1, probationTimestamp); + statement.setInt(2, rowId); statement.execute(); } catch (SQLException e) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index d579482c..ca7834d2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -150,10 +150,10 @@ public class SecureLoginEvent extends MessageHandler { if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - if (item.sanctionLevel > 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) { + if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) { this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo())); - } else if (item.sanctionLevel > 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) { - modToolSanctions.updateSanction(item.id, 0, 0); + } else if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) { + modToolSanctions.updateSanction(item.id, 0); } if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index e6b87afc..54ae2d60 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -28,7 +28,7 @@ public class ModToolSanctionInfoComposer extends MessageComposer { ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); Date probationEndTime; - Date probationStartTime = null; + Date probationStartTime; if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); @@ -37,7 +37,10 @@ public class ModToolSanctionInfoComposer extends MessageComposer { if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); - boolean prevItem = modToolSanctionItems.size() > 1; + ModToolSanctionItem prevItem = null; + if (modToolSanctionItems.get(modToolSanctionItems.size() - 2) != null) { + prevItem = modToolSanctionItems.get(modToolSanctionItems.size() - 2); + } ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1); @@ -47,50 +50,56 @@ public class ModToolSanctionInfoComposer extends MessageComposer { probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); + Date tradeLockedUntil = null; + + if (item.tradeLockedUntil > 0) { + tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000); + } + + this.response.init(Outgoing.ModToolSanctionInfoComposer); + + this.response.appendBoolean(prevItem != null && prevItem.probationTimestamp > 0); // has prev sanction + this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation + this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type + this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction + this.response.appendInt(30); // TODO: unused? + this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason + this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time + this.response.appendInt(0); // TODO: unused? + this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type + this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) + this.response.appendInt(30); // TODO: unused? + this.response.appendBoolean(item.isMuted); // muted + this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until + } else { + return cleanResponse(); } - Date tradeLockedUntil = null; - - if (item.tradeLockedUntil > 0) { - tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000); - } - - this.response.init(Outgoing.ModToolSanctionInfoComposer); - - this.response.appendBoolean(prevItem); // has prev sanction - this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation - this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type - this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction - this.response.appendInt(30); // TODO: unused? - this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason - this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time - this.response.appendInt(0); // TODO: unused? - this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type - this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours) - this.response.appendInt(30); // TODO: unused? - this.response.appendBoolean(item.isMuted); // muted - this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until - + } else { + return cleanResponse(); } - } else { - this.response.init(Outgoing.ModToolSanctionInfoComposer); - - this.response.appendBoolean(false); // has prev sanction - this.response.appendBoolean(false); // is on probation - this.response.appendString("ALERT"); // last sanction type - this.response.appendInt(0); // time of current sanction - this.response.appendInt(30); // TODO: unused? - this.response.appendString("cfh.reason.EMPTY"); // reason - this.response.appendString(Emulator.getDate().toString()); // probation start time - this.response.appendInt(0); // TODO: unused? - this.response.appendString("ALERT"); // next sanction type - this.response.appendInt(0); // time to be applied in next sanction (in hours) - this.response.appendInt(30); // TODO: unused? - this.response.appendBoolean(false); // muted - this.response.appendString(""); // trade locked until - } return this.response; } + + private ServerMessage cleanResponse() { + this.response.init(Outgoing.ModToolSanctionInfoComposer); + + this.response.appendBoolean(false); // has prev sanction + this.response.appendBoolean(false); // is on probation + this.response.appendString("ALERT"); // last sanction type + this.response.appendInt(0); // time of current sanction + this.response.appendInt(30); // TODO: unused? + this.response.appendString("cfh.reason.EMPTY"); // reason + this.response.appendString(Emulator.getDate().toString()); // probation start time + this.response.appendInt(0); // TODO: unused? + this.response.appendString("ALERT"); // next sanction type + this.response.appendInt(0); // time to be applied in next sanction (in hours) + this.response.appendInt(30); // TODO: unused? + this.response.appendBoolean(false); // muted + this.response.appendString(""); // trade locked until + + return this.response; + } } \ No newline at end of file From db32682fbcec717cde2d36e3ad31c40951b3c850 Mon Sep 17 00:00:00 2001 From: David Silva Date: Wed, 22 Jan 2020 20:56:56 +0100 Subject: [PATCH 025/153] fix(flooding): do not show mute icon if mute is due to flooding --- .../java/com/eu/habbo/habbohotel/commands/MuteCommand.java | 2 +- .../com/eu/habbo/habbohotel/modtool/ModToolSanctions.java | 2 +- src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java | 2 +- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- .../java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java | 2 +- src/main/java/com/eu/habbo/habbohotel/users/Habbo.java | 4 ++-- .../habbo/messages/incoming/handshake/SecureLoginEvent.java | 2 +- .../incoming/modtool/ModToolIssueDefaultSanctionEvent.java | 2 +- .../messages/incoming/modtool/ModToolSanctionMuteEvent.java | 2 +- src/main/java/com/eu/habbo/messages/rcon/MuteUser.java | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java index 919c43a7..24425e2c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MuteCommand.java @@ -43,7 +43,7 @@ public class MuteCommand extends Command { } } - habbo.mute(duration); + habbo.mute(duration, false); if (habbo.getHabboInfo().getCurrentRoom() != null) { habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java index 91ad713b..ea72d8bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -158,7 +158,7 @@ public class ModToolSanctions { switch (sanctionLevelItem.sanctionType) { case "ALERT": habbo.alert(reason); break; case "BAN": Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.sanctionHourLength, ModToolBanType.ACCOUNT, cfhTopic); break; - case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds); break; + case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds, false); break; default: break; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index 6b214a77..123a47c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -150,7 +150,7 @@ public class WordFilter { foundShit = true; if (habbo != null && word.muteTime > 0) { - habbo.mute(word.muteTime); + habbo.mute(word.muteTime, false); } } } 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 e88598a7..ffe6e746 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2971,7 +2971,7 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getHabboStats().mutedCount++; timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2))); habbo.getHabboStats().chatCounter = 0; - habbo.mute(timeOut); + habbo.mute(timeOut, true); } public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) { 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 c6ed428e..8322d624 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -210,7 +210,7 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable { return; } } else { - this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute")); + this.habbo.mute(Emulator.getConfig().getInt("hotel.wordfilter.automute"), false); } this.message = ""; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index 0838c76f..b3fb1399 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -378,14 +378,14 @@ public class Habbo implements Runnable { } } - public void mute(int seconds) { + public void mute(int seconds, boolean isFlood) { if (!this.hasPermission("acc_no_mute")) { int remaining = this.habboStats.addMuteTime(seconds); this.client.sendResponse(new FloodCounterComposer(remaining)); this.client.sendResponse(new MutedWhisperComposer(remaining)); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (room != null) { + if (room != null && !isFlood) { room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.MUTED).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index ca7834d2..86d75859 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -169,7 +169,7 @@ public class SecureLoginEvent extends MessageHandler { } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) { Date muteDuration = new Date((long) item.muteDuration * 1000); long diff = muteDuration.getTime() - Emulator.getDate().getTime(); - habbo.mute(Math.toIntExact(diff)); + habbo.mute(Math.toIntExact(diff), false); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java index bea0a0ff..3a0f770c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolIssueDefaultSanctionEvent.java @@ -30,7 +30,7 @@ public class ModToolIssueDefaultSanctionEvent extends MessageHandler { } else if (defaultSanction.muteLength > 0) { if (target != null) { - target.mute(defaultSanction.muteLength * 86400); + target.mute(defaultSanction.muteLength * 86400, false); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java index b7451cfe..cdd18350 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java @@ -47,7 +47,7 @@ public class ModToolSanctionMuteEvent extends MessageHandler { modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); } } else { - habbo.mute(60 * 60); + habbo.mute(60 * 60, false); habbo.alert(message); this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername())); } diff --git a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java index a83da553..b86893d1 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java @@ -21,7 +21,7 @@ public class MuteUser extends RCONMessage { if (json.duration == 0) { habbo.unMute(); } else { - habbo.mute(json.duration); + habbo.mute(json.duration, false); } } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET mute_end_timestamp = ? WHERE user_id = ? LIMIT 1")) { From cf422a574c002bd2dd68e019e2cb84fdb26dc0c7 Mon Sep 17 00:00:00 2001 From: skeletor Date: Thu, 23 Jan 2020 08:20:42 -0500 Subject: [PATCH 026/153] added additonal parameters to photo extra data json string --- sqlupdates/2_3_0_TO_2_3_1.sql | 1 + src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 sqlupdates/2_3_0_TO_2_3_1.sql diff --git a/sqlupdates/2_3_0_TO_2_3_1.sql b/sqlupdates/2_3_0_TO_2_3_1.sql new file mode 100644 index 00000000..6fbdb885 --- /dev/null +++ b/sqlupdates/2_3_0_TO_2_3_1.sql @@ -0,0 +1 @@ +UPDATE `emulator_settings` SET `value`='{\"t\":%timestamp%, \"u\":\"%id%\", \"n\":\"%username%\", \"s\":%user_id%, \"w\":\"%url%\"}' WHERE (`key`='camera.extradata'); 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 0632c0b8..04058ab5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -45,7 +45,7 @@ public class HabboInfo implements Runnable { private TIntIntHashMap currencies; private GamePlayer gamePlayer; private int photoRoomId; - private int photoTimestamp; + private long photoTimestamp; private String photoURL; private String photoJSON; private int webPublishTimestamp; @@ -430,11 +430,11 @@ public class HabboInfo implements Runnable { this.photoRoomId = roomId; } - public int getPhotoTimestamp() { + public long getPhotoTimestamp() { return this.photoTimestamp; } - public void setPhotoTimestamp(int photoTimestamp) { + public void setPhotoTimestamp(long photoTimestamp) { this.photoTimestamp = photoTimestamp; } From e8db4ce104f313b9b25be7e8ff25392c783e5514 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Thu, 23 Jan 2020 14:24:53 -0500 Subject: [PATCH 027/153] Revert "Merge branch 'patch-photo-extradata' into 'dev'" This reverts merge request !82 --- sqlupdates/2_3_0_TO_2_3_1.sql | 1 - src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 sqlupdates/2_3_0_TO_2_3_1.sql diff --git a/sqlupdates/2_3_0_TO_2_3_1.sql b/sqlupdates/2_3_0_TO_2_3_1.sql deleted file mode 100644 index 6fbdb885..00000000 --- a/sqlupdates/2_3_0_TO_2_3_1.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE `emulator_settings` SET `value`='{\"t\":%timestamp%, \"u\":\"%id%\", \"n\":\"%username%\", \"s\":%user_id%, \"w\":\"%url%\"}' WHERE (`key`='camera.extradata'); 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 04058ab5..0632c0b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -45,7 +45,7 @@ public class HabboInfo implements Runnable { private TIntIntHashMap currencies; private GamePlayer gamePlayer; private int photoRoomId; - private long photoTimestamp; + private int photoTimestamp; private String photoURL; private String photoJSON; private int webPublishTimestamp; @@ -430,11 +430,11 @@ public class HabboInfo implements Runnable { this.photoRoomId = roomId; } - public long getPhotoTimestamp() { + public int getPhotoTimestamp() { return this.photoTimestamp; } - public void setPhotoTimestamp(long photoTimestamp) { + public void setPhotoTimestamp(int photoTimestamp) { this.photoTimestamp = photoTimestamp; } From 0e23a04ccbadee428966703e9a41376b3d5c73cb Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 23 Jan 2020 19:55:53 +0000 Subject: [PATCH 028/153] Fixed ansi colors in IntelliJ Debug and on UNIX Systems. --- ...2_2_2_TO_2_3_0.sql => 2_2_2_TO_2_3_0-RC-1.sql} | 0 src/main/java/com/eu/habbo/Emulator.java | 15 +++++++++++---- src/main/java/com/eu/habbo/core/Logging.java | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) rename sqlupdates/{2_2_2_TO_2_3_0.sql => 2_2_2_TO_2_3_0-RC-1.sql} (100%) diff --git a/sqlupdates/2_2_2_TO_2_3_0.sql b/sqlupdates/2_2_2_TO_2_3_0-RC-1.sql similarity index 100% rename from sqlupdates/2_2_2_TO_2_3_0.sql rename to sqlupdates/2_2_2_TO_2_3_0-RC-1.sql diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index e82431ca..7c6eac1d 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -40,7 +40,7 @@ public final class Emulator { public static final String ANSI_YELLOW = "\u001B[33m"; - public final static String PREVIEW = "RC-1"; + public final static String PREVIEW = "RC-2"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -58,6 +58,8 @@ public final class Emulator { public static boolean isShuttingDown = false; public static boolean stopped = false; public static boolean debugging = false; + private static String classPath = System.getProperty("java.class.path"); + private static String osName = System.getProperty("os.name"); private static int timeStarted = 0; private static Runtime runtime; private static ConfigurationManager config; @@ -85,7 +87,9 @@ public final class Emulator { public static void main(String[] args) throws Exception { try { - AnsiConsole.systemInstall(); + if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) { + AnsiConsole.systemInstall(); + } Locale.setDefault(new Locale("en")); setBuild(); Emulator.stopped = false; @@ -197,7 +201,8 @@ public final class Emulator { Emulator.isShuttingDown = true; Emulator.isReady = false; Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "..."); - + String classPath = System.getProperty("java.class.path"); + String osName = System.getProperty("os.name"); try { if (Emulator.getPluginManager() != null) Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent()); @@ -255,8 +260,10 @@ public final class Emulator { Emulator.getDatabase().dispose(); } Emulator.stopped = true; - AnsiConsole.systemUninstall(); + if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) { + AnsiConsole.systemUninstall(); + } try { if (Emulator.threading != null) diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java index 1f3b1b51..c364f2ec 100644 --- a/src/main/java/com/eu/habbo/core/Logging.java +++ b/src/main/java/com/eu/habbo/core/Logging.java @@ -134,7 +134,7 @@ public class Logging { if (Emulator.getConfig().getBoolean("logging.debug")) { this.write(debugFileWriter, line.toString()); } - System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString()); + System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_RED + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString()); } public void logUserLine(Object line) { From 8f660626bc7ba6dc9a366b720309af76041e8be3 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 23 Jan 2020 19:57:38 +0000 Subject: [PATCH 029/153] Removed repetitive code added while testing. --- src/main/java/com/eu/habbo/Emulator.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 7c6eac1d..6999051a 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -201,8 +201,6 @@ public final class Emulator { Emulator.isShuttingDown = true; Emulator.isReady = false; Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "..."); - String classPath = System.getProperty("java.class.path"); - String osName = System.getProperty("os.name"); try { if (Emulator.getPluginManager() != null) Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent()); From e9c93b358901987b5d4b432e66728360b81b106c Mon Sep 17 00:00:00 2001 From: skeletor Date: Thu, 23 Jan 2020 16:19:58 -0500 Subject: [PATCH 030/153] Wired Condition Not in Team should return true if the user is not in any team --- .../interactions/wired/conditions/WiredConditionNotInTeam.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java index 8258e6fa..fba63af0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java @@ -34,6 +34,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { if (habbo.getHabboInfo().getGamePlayer() != null) { return !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); } + return true; // user is not part of any team } return false; From 593bb7453296a7f9838a36886d020812c198f0c4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 19:11:21 +0200 Subject: [PATCH 031/153] Make publishing pictures deduct duckets and make publish & purchase point type configurable --- sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql | 3 + .../camera/CameraPublishToWebEvent.java | 67 +++++++++++-------- .../incoming/camera/CameraPurchaseEvent.java | 57 ++++++++++------ .../CameraPublishWaitMessageComposer.java | 24 ++++--- .../com/eu/habbo/plugin/PluginManager.java | 7 ++ 5 files changed, 97 insertions(+), 61 deletions(-) create mode 100644 sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql diff --git a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql new file mode 100644 index 00000000..1b3fbb33 --- /dev/null +++ b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql @@ -0,0 +1,3 @@ +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish', '5'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish.type', '0'); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.type', '0'); diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java index 537765e4..5b16fead 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java @@ -1,8 +1,10 @@ package com.eu.habbo.messages.incoming.camera; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraPublishWaitMessageComposer; +import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer; import com.eu.habbo.plugin.events.users.UserPublishPictureEvent; import java.sql.Connection; @@ -10,40 +12,49 @@ import java.sql.PreparedStatement; import java.sql.SQLException; public class CameraPublishToWebEvent extends MessageHandler { + public static int CAMERA_PUBLISH_POINTS = 5; + public static int CAMERA_PUBLISH_POINTS_TYPE = 0; + @Override public void handle() throws Exception { - if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) { - if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) { - if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) { - int timestamp = Emulator.getIntUnixTimestamp(); + Habbo habbo = this.client.getHabbo(); - boolean published = false; - int timeDiff = timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp(); - int wait = 0; - if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) { - wait = timeDiff - Emulator.getConfig().getInt("camera.publish.delay"); - } else { - UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId()); - if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) { - statement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); - statement.setInt(2, publishPictureEvent.roomId); - statement.setInt(3, publishPictureEvent.timestamp); - statement.setString(4, publishPictureEvent.URL); - statement.execute(); - this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp); - published = true; - } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - } - } else { - return; - } - } + if (habbo == null) return; + if (habbo.getHabboInfo().getPhotoTimestamp() == 0) return; + if (habbo.getHabboInfo().getPhotoJSON().isEmpty()) return; + if (!habbo.getHabboInfo().getPhotoJSON().contains(habbo.getHabboInfo().getPhotoTimestamp() + "")) return; - this.client.sendResponse(new CameraPublishWaitMessageComposer(published, wait, published ? this.client.getHabbo().getHabboInfo().getPhotoURL() : "")); + if (habbo.getHabboInfo().getCurrencyAmount(CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE) < CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS) { + this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS)); + return; + } + + int timestamp = Emulator.getIntUnixTimestamp(); + + boolean isOk = false; + int cooldownLeft = Math.max(0, Emulator.getConfig().getInt("camera.publish.delay") - (timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp())); + + if (cooldownLeft == 0) { + UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId()); + + if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) { + statement.setInt(1, this.client.getHabbo().getHabboInfo().getId()); + statement.setInt(2, publishPictureEvent.roomId); + statement.setInt(3, publishPictureEvent.timestamp); + statement.setString(4, publishPictureEvent.URL); + statement.execute(); + + this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp); + this.client.getHabbo().givePoints(CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE, -CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS); + + isOk = true; + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); } } } + + this.client.sendResponse(new CameraPublishWaitMessageComposer(isOk, cooldownLeft, isOk ? this.client.getHabbo().getHabboInfo().getPhotoURL() : "")); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java index 351f4be5..173f3ca3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPurchaseEvent.java @@ -11,34 +11,47 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent; public class CameraPurchaseEvent extends MessageHandler { + public static int CAMERA_PURCHASE_CREDITS = 5; + public static int CAMERA_PURCHASE_POINTS = 5; + public static int CAMERA_PURCHASE_POINTS_TYPE = 0; + @Override public void handle() throws Exception { - if (this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits") || this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points")) { - this.client.sendResponse(new NotEnoughPointsTypeComposer(this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits"), this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points"), 0)); + if (this.client.getHabbo().getHabboInfo().getCredits() < CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS) { + this.client.sendResponse(new NotEnoughPointsTypeComposer(true, false, 0)); return; } - if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) { - if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) { - if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) { - if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) { - return; - } - HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON()); + if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE) < CameraPurchaseEvent.CAMERA_PURCHASE_POINTS) { + this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE)); + return; + } - if (photoItem != null) { - photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + "")); - photoItem.needsUpdate(true); - this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem); - this.client.sendResponse(new CameraPurchaseSuccesfullComposer()); - this.client.sendResponse(new AddHabboItemComposer(photoItem)); - this.client.sendResponse(new InventoryRefreshComposer()); - this.client.getHabbo().giveCredits(-Emulator.getConfig().getInt("camera.price.credits")); - this.client.getHabbo().givePixels(-Emulator.getConfig().getInt("camera.price.points")); - AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount")); - } - } - } + if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() == 0) return; + if (this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) return; + if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) + return; + + if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) { + return; + } + + HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), Emulator.getGameEnvironment().getItemManager().getItem(Emulator.getConfig().getInt("camera.item_id")), 0, 0, this.client.getHabbo().getHabboInfo().getPhotoJSON()); + + if (photoItem != null) { + photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + "")); + photoItem.needsUpdate(true); + + this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem); + + this.client.sendResponse(new CameraPurchaseSuccesfullComposer()); + this.client.sendResponse(new AddHabboItemComposer(photoItem)); + this.client.sendResponse(new InventoryRefreshComposer()); + + this.client.getHabbo().giveCredits(-CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS); + this.client.getHabbo().givePoints(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE, -CameraPurchaseEvent.CAMERA_PURCHASE_POINTS); + + AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount")); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java index f30d815c..defe9a68 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/camera/CameraPublishWaitMessageComposer.java @@ -5,25 +5,27 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; public class CameraPublishWaitMessageComposer extends MessageComposer { - public final boolean published; - public final int seconds; - public final String unknownString; + public final boolean isOk; + public final int cooldownSeconds; + public final String extraDataId; - public CameraPublishWaitMessageComposer(boolean published, int seconds, String unknownString) { - this.published = published; - this.seconds = seconds; - this.unknownString = unknownString; + public CameraPublishWaitMessageComposer(boolean isOk, int cooldownSeconds, String extraDataId) { + this.isOk = isOk; + this.cooldownSeconds = cooldownSeconds; + this.extraDataId = extraDataId; } @Override public ServerMessage compose() { this.response.init(Outgoing.CameraPublishWaitMessageComposer); - this.response.appendBoolean(this.published); - this.response.appendInt(this.seconds); - if (this.published) { - this.response.appendString(this.unknownString); + this.response.appendBoolean(this.isOk); + this.response.appendInt(this.cooldownSeconds); + + if (!this.extraDataId.isEmpty()) { + this.response.appendString(this.extraDataId); } + return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 9881701a..306fc1ff 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -22,6 +22,8 @@ import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.messages.PacketManager; +import com.eu.habbo.messages.incoming.camera.CameraPublishToWebEvent; +import com.eu.habbo.messages.incoming.camera.CameraPurchaseEvent; import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent; import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent; import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent; @@ -124,6 +126,11 @@ public class PluginManager { RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics"); ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.username.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,."); + CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS = Emulator.getConfig().getInt("camera.price.points.publish", 5); + CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.publish.type", 0); + CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS = Emulator.getConfig().getInt("camera.price.credits", 5); + CameraPurchaseEvent.CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points", 5); + CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 0); if (Emulator.isReady) { Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig(); From 35f13902ce4eb3a760ca55625cff3356c64187c6 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 19:36:59 +0200 Subject: [PATCH 032/153] Make avatar walk to switch if not already adjacent to it (fixes #313) --- .../items/interactions/InteractionSwitch.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java index 87543a07..e1761878 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java @@ -1,14 +1,18 @@ 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.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class InteractionSwitch extends InteractionDefault { public InteractionSwitch(ResultSet set, Item baseItem) throws SQLException { @@ -43,12 +47,22 @@ public class InteractionSwitch extends InteractionDefault { RoomTile closestTile = null; for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) { - closestTile = client.getHabbo().getRoomUnit().getCurrentLocation(); + closestTile = tile; } } - if (closestTile != null) { + if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { + List onSuccess = new ArrayList<>(); + onSuccess.add(() -> { + try { + this.onClick(client, room, objects); + } catch (Exception e) { + e.printStackTrace(); + } + }); + client.getHabbo().getRoomUnit().setGoalLocation(closestTile); + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>())); } } From f695f2f5b4ba28f4eb97f4c2f585becef702f6f2 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 19:52:58 +0200 Subject: [PATCH 033/153] Fix bot teleporting with wireds (fixes #315) --- .../interactions/wired/effects/WiredEffectBotTeleport.java | 2 +- .../java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java index a5662610..487b88f6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java @@ -107,7 +107,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { int currentEffect = bot.getRoomUnit().getEffectId(); room.giveEffect(bot.getRoomUnit(), 4, -1); - Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, bot.getRoomUnit()), WiredHandler.TELEPORT_DELAY + 1000); + Emulator.getThreading().run(() -> room.giveEffect(bot.getRoomUnit(), 0, -1), WiredHandler.TELEPORT_DELAY + 1000); Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? -0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY); break; } else { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 9e342d34..3a255ffb 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -55,6 +55,7 @@ public class RoomUnitTeleport implements Runnable { this.room.sendComposer(teleportMessage); this.room.updateHabbosAt(t.x, t.y); + this.room.updateBotsAt(t.x, t.y); topItem = room.getTopItemAt(x, y); if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) { From b425bb6856234b37ad988e413bb65d1f54d53f38 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:03:04 +0200 Subject: [PATCH 034/153] Fix avatars not rotating with wf_act_match_to_sshot (fixes #314) --- .../wired/effects/WiredEffectMatchFurni.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index e461c25b..9ee38399 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -60,6 +60,17 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { if (this.direction) { item.setRotation(setting.rotation); slideAnimation = false; + + room.scheduledTasks.add(() -> { + room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation).forEach(t -> { + room.updateBotsAt(t.x, t.y); + room.updateHabbosAt(t.x, t.y); + }); + room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation).forEach(t -> { + room.updateBotsAt(t.x, t.y); + room.updateHabbosAt(t.x, t.y); + }); + }); } //room.sendComposer(new ItemStateComposer(item).compose()); From 191ef7afad79f6d1f218cfca3dc5a6e7eedfa3b8 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:22:52 +0200 Subject: [PATCH 035/153] Make game gates unwalkable during a game (fixes #312) --- .../gates/InteractionBattleBanzaiGate.java | 15 ++++++++------ .../freeze/gates/InteractionFreezeGate.java | 20 ++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java index 5948ec9e..04def885 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; @@ -28,17 +29,19 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate { } @Override - public boolean isWalkable() { - Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); - if (room == null) - return false; + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - return (this.getExtradata() == null || this.getExtradata().isEmpty() || Integer.valueOf(this.getExtradata()) < 5) && ((room.getGame(BattleBanzaiGame.class))) == null || ((BattleBanzaiGame) (room.getGame(BattleBanzaiGame.class))).state.equals(GameState.IDLE); } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + public boolean isWalkable() { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + if (room == null) return false; + + Game game = room.getGame(BattleBanzaiGame.class); + + return game == null || game.getState() == GameState.IDLE; } //TODO: Move to upper class diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java index 96daf1d2..ec583fde 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java @@ -1,5 +1,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; @@ -27,18 +29,18 @@ public class InteractionFreezeGate extends InteractionGameGate { } @Override - public boolean isWalkable() { - if (this.getRoomId() == 0) - return false; - - return (this.getExtradata().isEmpty() || - Integer.valueOf(this.getExtradata()) < 5); - //((Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))) == null || - //!((FreezeGame)(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getGame(FreezeGame.class))).isRunning; + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + public boolean isWalkable() { + Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); + + if (room == null) return false; + + Game game = room.getGame(FreezeGame.class); + + return game == null || game.getState() == GameState.IDLE; } @Override From 015f72bce8ea1551702cf2bebc9c8cb0f744bf3e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:29:44 +0200 Subject: [PATCH 036/153] Fix forum message chat record context property (fixes #310) --- .../messages/outgoing/modtool/ModToolIssueChatlogComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java index dd73279a..ee8b3830 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java @@ -61,7 +61,7 @@ public class ModToolIssueChatlogComposer extends MessageComposer { this.response.appendInt(this.issue.threadId); if (this.type == ModToolIssueChatlogType.FORUM_COMMENT) { - ModToolChatRecordDataContext.GROUP_ID.append(this.response); + ModToolChatRecordDataContext.MESSAGE_ID.append(this.response); this.response.appendInt(this.issue.commentId); } } else if (this.issue.type == ModToolTicketType.PHOTO) { From 1b5517f677dcfcc83e7e9cafdedc08edcf858a4e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:34:27 +0200 Subject: [PATCH 037/153] Clear dance when avatar idles (fixes #309) --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 5 +++++ 1 file changed, 5 insertions(+) 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 ffe6e746..276e6d88 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4160,6 +4160,11 @@ public class Room implements Comparable, ISerialize, Runnable { public void idle(Habbo habbo) { habbo.getRoomUnit().setIdle(); + + if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) { + this.dance(habbo, DanceType.NONE); + } + this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); } From 5eca88d501b34a2fe6e1e75616471298eb26fb2e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:41:14 +0200 Subject: [PATCH 038/153] Fix modtool room visit logs for offline users (fixes #308) --- .../eu/habbo/habbohotel/modtool/ModToolManager.java | 8 ++++---- .../modtool/ModToolRequestRoomVisitsEvent.java | 8 +++++--- .../modtool/ModToolUserRoomVisitsComposer.java | 12 ++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 18f546b1..8a10edbb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -278,12 +278,12 @@ public class ModToolManager { return chatlogs; } - public THashSet requestUserRoomVisits(Habbo habbo) { + public THashSet getUserRoomVisits(int userId) { THashSet roomVisits = new THashSet<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? AND timestamp >= ? ORDER BY timestamp DESC LIMIT 50")) { - statement.setInt(1, habbo.getHabboInfo().getId()); - statement.setInt(2, Emulator.getIntUnixTimestamp() - 84600); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.name, room_enter_log.* FROM room_enter_log INNER JOIN rooms ON rooms.id = room_enter_log.room_id WHERE user_id = ? ORDER BY timestamp DESC LIMIT 50")) { + statement.setInt(1, userId); + try (ResultSet set = statement.executeQuery()) { while (set.next()) { roomVisits.add(new ModToolRoomVisit(set)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java index 2725aa50..348cb10a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestRoomVisitsEvent.java @@ -3,6 +3,7 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.modtool.ModToolUserRoomVisitsComposer; @@ -12,10 +13,11 @@ public class ModToolRequestRoomVisitsEvent extends MessageHandler { if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { int userId = this.packet.readInt(); - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); + HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId); - if (habbo != null) - this.client.sendResponse(new ModToolUserRoomVisitsComposer(habbo, Emulator.getGameEnvironment().getModToolManager().requestUserRoomVisits(habbo))); + if (habboInfo != null) { + this.client.sendResponse(new ModToolUserRoomVisitsComposer(habboInfo, Emulator.getGameEnvironment().getModToolManager().getUserRoomVisits(userId))); + } } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java index 25ffcc8a..1ccc19a3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserRoomVisitsComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.modtool; import com.eu.habbo.habbohotel.modtool.ModToolRoomVisit; -import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -11,19 +11,19 @@ import java.util.Calendar; import java.util.TimeZone; public class ModToolUserRoomVisitsComposer extends MessageComposer { - private final Habbo habbo; + private final HabboInfo habboInfo; private final THashSet roomVisits; - public ModToolUserRoomVisitsComposer(Habbo habbo, THashSet roomVisits) { - this.habbo = habbo; + public ModToolUserRoomVisitsComposer(HabboInfo habboInfo, THashSet roomVisits) { + this.habboInfo = habboInfo; this.roomVisits = roomVisits; } @Override public ServerMessage compose() { this.response.init(Outgoing.ModToolUserRoomVisitsComposer); - this.response.appendInt(this.habbo.getHabboInfo().getId()); - this.response.appendString(this.habbo.getHabboInfo().getUsername()); + this.response.appendInt(this.habboInfo.getId()); + this.response.appendString(this.habboInfo.getUsername()); this.response.appendInt(this.roomVisits.size()); Calendar cal = Calendar.getInstance(TimeZone.getDefault()); From f2966b837c690befd84a9d006b46d78695ebe0b5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 20:58:29 +0200 Subject: [PATCH 039/153] Make multiheight items not change height if there is a furni on top (fixes #302) --- .../items/interactions/InteractionMultiHeight.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java index f73af35e..dead68c8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java @@ -2,10 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; @@ -13,9 +10,12 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import gnu.trove.set.hash.THashSet; +import org.apache.commons.math3.util.Pair; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class InteractionMultiHeight extends HabboItem { public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { @@ -55,6 +55,11 @@ public class InteractionMultiHeight extends HabboItem { if (objects.length > 0) { if (objects[0] instanceof Integer && room != null) { + HabboItem topItem = room.getTopItemAt(this.getX(), this.getY()); + if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top + return; + } + this.needsUpdate(true); if (this.getExtradata().length() == 0) From 72adc5325d9cd0d8bd462ee2d7dfc25111689030 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 24 Jan 2020 22:09:38 +0200 Subject: [PATCH 040/153] Add random state furni (fixes #305) --- .../habbo/habbohotel/items/ItemManager.java | 1 + .../habbohotel/items/RandomStateParams.java | 41 ++++++++++++++++++ .../interactions/InteractionRandomState.java | 42 +++++++++++++++++++ .../com/eu/habbo/messages/PacketManager.java | 1 + .../eu/habbo/messages/incoming/Incoming.java | 1 + .../rooms/items/UseRandomStateItemEvent.java | 29 +++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java create mode 100644 src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.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 a2d7f55c..cde2f0e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -177,6 +177,7 @@ public class ItemManager { 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)); + this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class)); this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java new file mode 100644 index 00000000..931be676 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java @@ -0,0 +1,41 @@ +package com.eu.habbo.habbohotel.items; + +import com.eu.habbo.Emulator; + +import java.util.Arrays; + +public class RandomStateParams { + private int states = -1; + private int delay = -1; + + public RandomStateParams(String customparams) throws Exception { + Arrays.stream(customparams.split(",")).forEach(pair -> { + String[] keyValue = pair.split("="); + + if (keyValue.length != 2) return; + + switch (keyValue[0]) { + case "states": + this.states = Integer.parseInt(keyValue[1]); + break; + case "delay": + this.delay = Integer.parseInt(keyValue[1]); + break; + default: + Emulator.getLogging().logDebugLine("RandomStateParams: unknown key: " + keyValue[0]); + break; + } + }); + + if (this.states < 0) throw new Exception("RandomStateParams: states not defined"); + if (this.delay < 0) throw new Exception("RandomStateParams: states not defined"); + } + + public int getStates() { + return states; + } + + public int getDelay() { + return delay; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java new file mode 100644 index 00000000..c28ee163 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java @@ -0,0 +1,42 @@ +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.RandomStateParams; +import com.eu.habbo.habbohotel.rooms.Room; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionRandomState extends InteractionDefault { + public InteractionRandomState(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionRandomState(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + + this.setExtradata(""); + room.updateItemState(this); + } + + public void onRandomStateClick(GameClient client, Room room) throws Exception { + RandomStateParams params = new RandomStateParams(this.getBaseItem().getCustomParams()); + + this.setExtradata(""); + room.updateItemState(this); + + int randomState = Emulator.getRandom().nextInt(params.getStates()) + 1; + + Emulator.getThreading().run(() -> { + this.setExtradata(randomState + ""); + room.updateItemState(this); + }, params.getDelay()); + } +} diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 8bd37ca8..4f4cb8ad 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -440,6 +440,7 @@ public class PacketManager { this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class); this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class); this.registerHandler(Incoming.RoomUnFavoriteEvent, RoomUnFavoriteEvent.class); + this.registerHandler(Incoming.UseRandomStateItemEvent, UseRandomStateItemEvent.class); } void registerPolls() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 87fb1494..464c76b7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -216,6 +216,7 @@ public class Incoming { public static final int PostItRequestDataEvent = 3964; public static final int PostItSaveDataEvent = 3666; public static final int PostItDeleteEvent = 3336; + public static final int UseRandomStateItemEvent = 3617; public static final int MySanctionStatusEvent = 2746; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java new file mode 100644 index 00000000..0b2e6ba9 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java @@ -0,0 +1,29 @@ +package com.eu.habbo.messages.incoming.rooms.items; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionRandomState; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.MessageHandler; + +public class UseRandomStateItemEvent extends MessageHandler { + @Override + public void handle() throws Exception { + try { + int itemId = this.packet.readInt(); + int state = this.packet.readInt(); + + Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + + HabboItem item = room.getHabboItem(itemId); + + if (item == null || !(item instanceof InteractionRandomState)) + return; + + InteractionRandomState randomStateItem = (InteractionRandomState)item; + randomStateItem.onRandomStateClick(this.client, room); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } + } +} From 2622140d5a0cb56aaf34390df5372773610b44f4 Mon Sep 17 00:00:00 2001 From: David Silva Date: Fri, 24 Jan 2020 22:57:18 +0100 Subject: [PATCH 041/153] fix(ModToolSanctionEvents): run if timestamp is back to 0 --- .../incoming/modtool/ModToolSanctionAlertEvent.java | 2 ++ .../messages/incoming/modtool/ModToolSanctionBanEvent.java | 2 ++ .../messages/incoming/modtool/ModToolSanctionMuteEvent.java | 6 ++++++ .../incoming/modtool/ModToolSanctionTradeLockEvent.java | 2 ++ 4 files changed, 12 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java index 98e27cc6..c0f8bae8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionAlertEvent.java @@ -36,6 +36,8 @@ public class ModToolSanctionAlertEvent extends MessageHandler { if (item != null && item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + } else { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); } } else { modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java index 59e05e89..c3035034 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionBanEvent.java @@ -60,6 +60,8 @@ public class ModToolSanctionBanEvent extends MessageHandler { if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + } else { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); } } else { modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java index cdd18350..c99eee68 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionMuteEvent.java @@ -41,6 +41,12 @@ public class ModToolSanctionMuteEvent extends MessageHandler { int muteDurationTimestamp = Math.toIntExact(new Date( System.currentTimeMillis() + (modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000); + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp); + } else { + ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); + + int muteDurationTimestamp = Math.toIntExact(new Date( System.currentTimeMillis() + (modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000); + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp); } } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java index 1969da0f..48e14a38 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolSanctionTradeLockEvent.java @@ -36,6 +36,8 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler { if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) { modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); + } else { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0); } } else { modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, duration, false, 0); From 4723ecebbe6f1bcdce0e240d5965a0c21a63bc36 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 25 Jan 2020 18:21:40 +0200 Subject: [PATCH 042/153] Add gitlab-ci file --- .gitlab-ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..8f4ecd13 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +image: maven:latest + +cache: + paths: + - target/ + +build-dev: + script: + - mvn package + only: + - dev + artifacts: + paths: + - target/Habbo-*.jar \ No newline at end of file From cdf06f64ea5edca9dd881b57697252340fa20a23 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 25 Jan 2020 20:05:12 +0200 Subject: [PATCH 043/153] Add CI builds for master --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f4ecd13..a0cacc72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,11 +4,12 @@ cache: paths: - target/ -build-dev: +build: script: - mvn package only: - dev + - master artifacts: paths: - target/Habbo-*.jar \ No newline at end of file From aeafc99468e766c018f6293ac7b91455510a0d68 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 25 Jan 2020 20:20:04 +0200 Subject: [PATCH 044/153] Add custom timer support (closes #320) --- .../com/eu/habbo/messages/PacketManager.java | 1 + .../eu/habbo/messages/incoming/Incoming.java | 2 ++ .../HotelViewRequestSecondsUntilEvent.java | 20 ++++++++++++++++ .../eu/habbo/messages/outgoing/Outgoing.java | 1 + .../HotelViewSecondsUntilComposer.java | 24 +++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java create mode 100644 src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 4f4cb8ad..ccc54701 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -339,6 +339,7 @@ public class PacketManager { this.registerHandler(Incoming.HotelViewRequestBadgeRewardEvent, HotelViewRequestBadgeRewardEvent.class); this.registerHandler(Incoming.HotelViewClaimBadgeRewardEvent, HotelViewClaimBadgeRewardEvent.class); this.registerHandler(Incoming.HotelViewRequestLTDAvailabilityEvent, HotelViewRequestLTDAvailabilityEvent.class); + this.registerHandler(Incoming.HotelViewRequestSecondsUntilEvent, HotelViewRequestSecondsUntilEvent.class); } private void registerInventory() throws Exception { diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 464c76b7..6b13ed2e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -351,6 +351,8 @@ public class Incoming { public static final int LoveLockStartConfirmEvent = 3775; public static final int HotelViewRequestLTDAvailabilityEvent = 410; + public static final int HotelViewRequestSecondsUntilEvent = 271; + public static final int PurchaseTargetOfferEvent = 1826; public static final int TargetOfferStateEvent = 2041; public static final int StopBreedingEvent = 2713; diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java new file mode 100644 index 00000000..c7a6be24 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewRequestSecondsUntilEvent.java @@ -0,0 +1,20 @@ +package com.eu.habbo.messages.incoming.hotelview; + +import com.eu.habbo.Emulator; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.hotelview.HotelViewSecondsUntilComposer; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +public class HotelViewRequestSecondsUntilEvent extends MessageHandler { + private static DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm"); + + @Override + public void handle() throws Exception { + String date = this.packet.readString(); + int secondsUntil = Math.max(0, (int) (dateFormat.parse(date).getTime() / 1000) - Emulator.getIntUnixTimestamp()); + + this.client.sendResponse(new HotelViewSecondsUntilComposer(date, secondsUntil)); + } +} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java index cc7efef7..037efc81 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java @@ -525,6 +525,7 @@ public class Outgoing { public final static int UnknownRoomViewerComposer = 3523; public final static int ErrorLoginComposer = 4000; public final static int HotelViewNextLTDAvailableComposer = 44; + public final static int HotelViewSecondsUntilComposer = 3926; public final static int UnknownRoomDesktopComposer = 69; public final static int UnknownGuildComposer3 = 876; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java new file mode 100644 index 00000000..d258dc2a --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/outgoing/hotelview/HotelViewSecondsUntilComposer.java @@ -0,0 +1,24 @@ +package com.eu.habbo.messages.outgoing.hotelview; + +import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.MessageComposer; +import com.eu.habbo.messages.outgoing.Outgoing; + +public class HotelViewSecondsUntilComposer extends MessageComposer { + private final String dateString; + private final int seconds; + + public HotelViewSecondsUntilComposer(String dateString, int seconds) { + this.dateString = dateString; + this.seconds = seconds; + } + + @Override + public ServerMessage compose() { + this.response.init(Outgoing.HotelViewSecondsUntilComposer); + this.response.appendString(this.dateString); + this.response.appendInt(this.seconds); + + return this.response; + } +} From 8d6677ab17dcce430086e62fd2c1ebd42decfd8d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 15:26:38 +0200 Subject: [PATCH 045/153] Show guild creator join date (closes #326) --- .../eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java index f52c7dff..73e98a26 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java @@ -49,7 +49,7 @@ public class GuildMembersComposer extends MessageComposer { this.response.appendInt(member.getUserId()); this.response.appendString(member.getUsername()); this.response.appendString(member.getLook()); - this.response.appendString(member.getRank().type < 3 && member.getRank().type > 0 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : ""); + this.response.appendString(member.getRank().type < 3 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : ""); } this.response.appendBoolean(this.isAdmin); From 1cfbac1cfba4a414ae312ffafe40288c45ea782c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 15:36:08 +0200 Subject: [PATCH 046/153] Delay puzzle box mover's goal location setting (closes #335) --- .../habbohotel/items/interactions/InteractionPuzzleBox.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 21d42d2a..11867ace 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -1,5 +1,6 @@ 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.*; @@ -56,7 +57,7 @@ public class InteractionPuzzleBox extends HabboItem { if (item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) { room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, offset, room).compose()); - client.getHabbo().getRoomUnit().setGoalLocation(boxLocation); + room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); this.needsUpdate(true); } } From 9a161e1184c48c11e8db3363ce122e7e995350da Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 16:36:05 +0200 Subject: [PATCH 047/153] Make user walk to puzzle box if not adjacent (closes #336) --- .../interactions/InteractionPuzzleBox.java | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 11867ace..355acb8b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -1,16 +1,17 @@ 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.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Optional; public class InteractionPuzzleBox extends HabboItem { public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException { @@ -26,40 +27,59 @@ public class InteractionPuzzleBox extends HabboItem { if (client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) return; - if (!RoomLayout.tilesAdjecent(room.getLayout().getTile(super.getX(), super.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) - return; - - RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY()); - client.getHabbo().getRoomUnit().lookAtPoint(boxLocation); - room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); + RoomUserRotation rotation = null; - switch (client.getHabbo().getRoomUnit().getBodyRotation()) { - case NORTH_EAST: - case NORTH_WEST: - case SOUTH_EAST: - case SOUTH_WEST: - return; + if (this.getX() == client.getHabbo().getRoomUnit().getX()) { + if (this.getY() == client.getHabbo().getRoomUnit().getY() + 1) { + rotation = RoomUserRotation.SOUTH; + } else if (this.getY() == client.getHabbo().getRoomUnit().getY() - 1) { + rotation = RoomUserRotation.NORTH; + } + } else if (this.getY() == client.getHabbo().getRoomUnit().getY()) { + if (this.getX() == client.getHabbo().getRoomUnit().getX() + 1) { + rotation = RoomUserRotation.EAST; + } else if (this.getX() == client.getHabbo().getRoomUnit().getX() - 1) { + rotation = RoomUserRotation.WEST; + } } - RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getBodyRotation().getValue()); + if (rotation == null) { + Optional nearestTile = Arrays.stream( + new RoomTile[]{ + room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH.getValue()), + room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH.getValue()), + room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.EAST.getValue()), + room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.WEST.getValue()) + } + ) + .filter(t -> t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) + .min(Comparator.comparingDouble(a -> a.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))); - if (tile == null || !room.tileWalkable(tile) || room.hasHabbosAt(tile.x, tile.y)) { + nearestTile.ifPresent(roomTile -> client.getHabbo().getRoomUnit().setGoalLocation(roomTile)); return; } - double offset = room.getStackHeight(tile.x, tile.y, false) - this.getZ(); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue()); - if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), client.getHabbo().getRoomUnit().getBodyRotation().getValue()))) + if (tile == null || room.hasHabbosAt(tile.x, tile.y)) { + return; + } + + if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), rotation.getValue()))) return; HabboItem item = room.getTopItemAt(tile.x, tile.y); - if (item == null || (item.getZ() <= this.getZ() && item.getBaseItem().allowWalk())) { - room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, offset, room).compose()); - room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); - this.needsUpdate(true); - } + if (item != null && !room.getTopItemAt(tile.x, tile.y).getBaseItem().allowStack()) return; + + this.setZ(room.getStackHeight(tile.x, tile.y, false)); + this.needsUpdate(true); + room.updateItem(this); + + room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose()); + room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); + this.needsUpdate(true); } @Override From b439774c1132dec00414426d16fc573af9522126 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 19:17:11 +0200 Subject: [PATCH 048/153] Refactor guild rank names and fix #327 --- src/main/java/com/eu/habbo/Emulator.java | 6 +++--- src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java | 4 ++-- .../java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java | 4 ++-- .../incoming/guilds/GuildConfirmRemoveMemberEvent.java | 2 +- .../incoming/guilds/GuildDeclineMembershipEvent.java | 2 +- .../messages/incoming/guilds/GuildRemoveMemberEvent.java | 2 +- .../messages/incoming/guilds/RequestGuildMembersEvent.java | 2 +- .../habbo/messages/outgoing/guilds/GuildInfoComposer.java | 6 +++--- .../guilds/forums/ThreadUpdatedMessageComposer.java | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 6999051a..b73fb65f 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -118,13 +118,13 @@ public final class Emulator { Emulator.texts = new TextsManager(); new CleanerThread(); Emulator.gameServer = new GameServer(getConfig().getValue("game.host", "127.0.0.1"), getConfig().getInt("game.port", 30000)); - Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); + //Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); Emulator.gameEnvironment = new GameEnvironment(); Emulator.gameEnvironment.load(); Emulator.gameServer.initializePipeline(); Emulator.gameServer.connect(); - Emulator.rconServer.initializePipeline(); - Emulator.rconServer.connect(); + //Emulator.rconServer.initializePipeline(); + //Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java index e0c5c833..a7afa1b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildRank.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.guilds; public enum GuildRank { - ADMIN(0), - MOD(1), + OWNER(0), + ADMIN(1), MEMBER(2), REQUESTED(3), DELETED(4); diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java index 172e29e2..3d2437e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -79,8 +79,8 @@ public class ModToolIssue implements ISerialize { message.appendString(this.senderUsername); //Reporter user name. message.appendInt(this.reportedId); //Reported user ID. message.appendString(this.reportedUsername); //Reported user name. - message.appendInt(this.modId); //MOD User ID? - message.appendString(this.modName); //MOD User name? + message.appendInt(this.modId); //ADMIN User ID? + message.appendString(this.modName); //ADMIN User name? message.appendString(this.message); message.appendInt(0); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java index 5d12d01d..9e04a545 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildConfirmRemoveMemberEvent.java @@ -18,7 +18,7 @@ public class GuildConfirmRemoveMemberEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.ADMIN)) || this.client.getHabbo().hasPermission("acc_guild_admin")) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.OWNER)) || this.client.getHabbo().hasPermission("acc_guild_admin")) { Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); int count = 0; if (room != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java index e2aede92..e67945d6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeclineMembershipEvent.java @@ -22,7 +22,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission("acc_guild_admin")) { guild.decreaseRequestCount(); Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, ""))); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java index cfcada6c..beb69560 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java @@ -22,7 +22,7 @@ public class GuildRemoveMemberEvent extends MessageHandler { if (guild != null) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); - if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) { + if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission("acc_guild_admin")) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo); Emulator.getPluginManager().fireEvent(removedMemberEvent); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java index b1c1e873..f8ec7693 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java @@ -21,7 +21,7 @@ public class RequestGuildMembersEvent extends MessageHandler { boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin"); if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) { GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo()); - isAdmin = member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.MOD)); + isAdmin = member != null && (member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN)); } this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, pageId, levelId, query))); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java index 5cf963a9..9a106a08 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java @@ -36,13 +36,13 @@ public class GuildInfoComposer extends MessageComposer { this.response.appendString(this.guild.getBadge()); this.response.appendInt(this.guild.getRoomId()); this.response.appendString(this.guild.getRoomName()); - //this.response.appendInt(this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() ? 3 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) || this.member.getRank().equals(GuildRank.MOD) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : 0)))); - this.response.appendInt(adminPermissions ? 4 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : (this.member.getRank().equals(GuildRank.MOD) ? 3 : (this.member.getRank().equals(GuildRank.ADMIN) ? 4 : 0)))))); + //this.response.appendInt(this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() ? 3 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) || this.member.getRank().equals(GuildRank.ADMIN) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : 0)))); + this.response.appendInt(adminPermissions ? 4 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : (this.member.getRank().equals(GuildRank.ADMIN) ? 3 : (this.member.getRank().equals(GuildRank.OWNER) ? 4 : 0)))))); this.response.appendInt(this.guild.getMemberCount()); //Member count. this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); //favorite group this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); - this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.MOD) || + this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.ADMIN) || //Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.guild.getOwnerId()); this.response.appendString(this.guild.getOwnerName()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java index c7138ef8..4d2453ef 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java @@ -42,8 +42,8 @@ public class ThreadUpdatedMessageComposer extends MessageComposer { } if (this.habbo.getHabboInfo().getId() != guild.getOwnerId() || - guild.canModForum().state == 2 && (Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.ADMIN - || Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.MOD) + guild.canModForum().state == 2 && (Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.OWNER + || Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.ADMIN) || this.habbo.hasPermission("acc_modtool_ticket_q")) { this.thread.setPinned(isPinned); this.thread.setLocked(isLocked); From fe78102678d8550d26c854427f3aa462aade960f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 19:43:17 +0200 Subject: [PATCH 049/153] Fix wf_act_match_to_sshot packet sending (closes #338) --- .../wired/effects/WiredEffectMatchFurni.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 9ee38399..796eca31 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -57,7 +57,9 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { int oldRotation = item.getRotation(); boolean slideAnimation = true; - if (this.direction) { + double offsetZ = 0; + + if (this.direction && item.getRotation() != setting.rotation) { item.setRotation(setting.rotation); slideAnimation = false; @@ -73,12 +75,9 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { }); } - //room.sendComposer(new ItemStateComposer(item).compose()); - room.sendComposer(new FloorItemUpdateComposer(item).compose()); + RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y); if (this.position) { - RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y); - if (t != null) { if (t.state != RoomTileState.INVALID) { boolean canMove = true; @@ -111,23 +110,27 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { if (highestZ != -1d) { tilesToUpdate.addAll(tiles); - double offsetZ = highestZ - item.getZ(); + offsetZ = highestZ - item.getZ(); double totalHeight = item.getZ() + offsetZ; - if(totalHeight > 40) break; + if (totalHeight > 40) break; tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation)); if (!slideAnimation) { item.setX(t.x); item.setY(t.y); } - - room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose()); } } } } } + if (slideAnimation && t != null) { + room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose()); + } else { + room.updateItem(item); + } + item.needsUpdate(true); } } From 50c7b1d3f4fa66d8bdfaf1db9d67f5b4a7de5fc9 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 20:45:44 +0200 Subject: [PATCH 050/153] Fix room promotions (closes #337) --- sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql | 7 +++ .../habbohotel/navigation/EventCategory.java | 43 +++++++++++++++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 16 ++++--- .../habbo/habbohotel/rooms/RoomPromotion.java | 29 ++++++++++-- .../eu/habbo/messages/incoming/Incoming.java | 2 +- .../promotions/BuyRoomPromotionEvent.java | 6 ++- .../eu/habbo/messages/outgoing/Outgoing.java | 3 +- .../NewNavigatorEventCategoriesComposer.java | 47 +++++-------------- .../RoomPromotionMessageComposer.java | 21 +++------ .../com/eu/habbo/plugin/PluginManager.java | 12 ++++- 10 files changed, 124 insertions(+), 62 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java diff --git a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql index 1b3fbb33..26b22d5d 100644 --- a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql +++ b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql @@ -1,3 +1,10 @@ INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish', '5'); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish.type', '0'); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.type', '0'); + +ALTER TABLE `room_promotions` +ADD COLUMN `start_timestamp` int(11) NOT NULL DEFAULT -1 AFTER `end_timestamp`; +ALTER TABLE `room_promotions` +ADD COLUMN `category` int(11) NOT NULL DEFAULT 0 AFTER `start_timestamp`; + +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('navigator.eventcategories', '1,Hottest Events,false;2,Parties & Music,true;3,Role Play,true;4,Help Desk,true;5,Trading,true;6,Games,true;7,Debates & Discussions,true;8,Grand Openings,true;9,Friending,true;10,Jobs,true;11,Group Events,true'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java b/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java new file mode 100644 index 00000000..264c8943 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/EventCategory.java @@ -0,0 +1,43 @@ +package com.eu.habbo.habbohotel.navigation; + +import com.eu.habbo.messages.ServerMessage; + +public class EventCategory { + private int id; + private String caption; + private boolean visible; + + public EventCategory(int id, String caption, boolean visible) { + this.id = id; + this.caption = caption; + this.visible = visible; + } + + public EventCategory(String serialized) throws Exception { + String[] parts = serialized.split(","); + + if (parts.length != 3) throw new Exception("A serialized event category should contain 3 fields"); + + this.id = Integer.valueOf(parts[0]); + this.caption = parts[1]; + this.visible = parts[2].equalsIgnoreCase("true"); + } + + public int getId() { + return id; + } + + public String getCaption() { + return caption; + } + + public boolean isVisible() { + return visible; + } + + public void serialize(ServerMessage message) { + message.appendInt(this.id); + message.appendString(this.caption); + message.appendBoolean(this.visible); + } +} 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 276e6d88..708cfa12 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2095,25 +2095,29 @@ public class Room implements Comparable, ISerialize, Runnable { return ""; } - public void createPromotion(String title, String description) { + public void createPromotion(String title, String description, int category) { this.promoted = true; if (this.promotion == null) { - this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60)); + this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60), Emulator.getIntUnixTimestamp(), category); } else { this.promotion.setTitle(title); this.promotion.setDescription(description); this.promotion.setEndTimestamp(Emulator.getIntUnixTimestamp() + (120 * 60)); + this.promotion.setCategory(category); } - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp, start_timestamp, category) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?, category = ?")) { statement.setInt(1, this.id); statement.setString(2, title); statement.setString(3, description); statement.setInt(4, this.promotion.getEndTimestamp()); - statement.setString(5, this.promotion.getTitle()); - statement.setString(6, this.promotion.getDescription()); - statement.setInt(7, this.promotion.getEndTimestamp()); + statement.setInt(5, this.promotion.getStartTimestamp()); + statement.setInt(6, category); + statement.setString(7, this.promotion.getTitle()); + statement.setString(8, this.promotion.getDescription()); + statement.setInt(9, this.promotion.getEndTimestamp()); + statement.setInt(10, this.promotion.getCategory()); statement.execute(); } catch (SQLException e) { Emulator.getLogging().logSQLException(e); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java index 6aeae74f..fa43278b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -13,12 +13,16 @@ public class RoomPromotion { private String title; private String description; private int endTimestamp; + private int startTimestamp; + private int category; - public RoomPromotion(Room room, String title, String description, int endTimestamp) { + public RoomPromotion(Room room, String title, String description, int endTimestamp, int startTimestamp, int category) { this.room = room; this.title = title; this.description = description; this.endTimestamp = endTimestamp; + this.startTimestamp = startTimestamp; + this.category = category; } public RoomPromotion(Room room, ResultSet set) throws SQLException { @@ -26,14 +30,17 @@ public class RoomPromotion { this.title = set.getString("title"); this.description = set.getString("description"); this.endTimestamp = set.getInt("end_timestamp"); + this.startTimestamp = set.getInt("start_timestamp"); + this.category = set.getInt("category"); } public void save() { if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ? WHERE room_id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE room_promotions SET title = ?, description = ?, category = ? WHERE room_id = ?")) { statement.setString(1, this.title); statement.setString(2, this.description); - statement.setInt(3, this.room.getId()); + statement.setInt(3, this.category); + statement.setInt(4, this.room.getId()); statement.executeUpdate(); } catch (SQLException e) { Emulator.getLogging().logSQLException(e); @@ -74,4 +81,20 @@ public class RoomPromotion { public void addEndTimestamp(int time) { this.endTimestamp += time; } + + public int getStartTimestamp() { + return startTimestamp; + } + + public void setStartTimestamp(int startTimestamp) { + this.startTimestamp = startTimestamp; + } + + public int getCategory() { + return category; + } + + public void setCategory(int category) { + this.category = category; + } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 6b13ed2e..e5cf0ba7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -259,6 +259,7 @@ public class Incoming { public static final int RequestDeleteRoomEvent = 532; public static final int RequestPromotionRoomsEvent = 1075; public static final int BuyRoomPromotionEvent = 777; + public static final int EditRoomPromotionMessageEvent = 3991; public static final int RequestGuideToolEvent = 1922; public static final int RequestGuideAssistanceEvent = 3338; public static final int GuideUserTypingEvent = 519; @@ -314,7 +315,6 @@ public class Incoming { public static final int YoutubeRequestStateChange = 3005; public static final int YoutubeRequestPlaylistChange = 2069; - public static final int EditRoomPromotionMessageEvent = 3707; public static final int HotelViewRequestBadgeRewardEvent = 2318; public static final int HotelViewClaimBadgeRewardEvent = -1; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java index 948d0b08..dc5278c5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer; import com.eu.habbo.messages.outgoing.catalog.PurchaseOKComposer; +import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesComposer; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; public class BuyRoomPromotionEvent extends MessageHandler { @@ -20,6 +21,9 @@ public class BuyRoomPromotionEvent extends MessageHandler { String description = this.packet.readString(); int categoryId = this.packet.readInt(); + if (NewNavigatorEventCategoriesComposer.CATEGORIES.stream().noneMatch(c -> c.getId() == categoryId)) + return; + CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPage(pageId); if (page != null) { @@ -35,7 +39,7 @@ public class BuyRoomPromotionEvent extends MessageHandler { if (room.isPromoted()) { room.getPromotion().addEndTimestamp(120 * 60); } else { - room.createPromotion(title, description); + room.createPromotion(title, description, categoryId); } if (room.isPromoted()) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java index 037efc81..b1d7dd27 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java @@ -388,13 +388,12 @@ public class Outgoing { public final static int AlertPurchaseUnavailableComposer = 3770; // PRODUCTION-201611291003-338511768 public final static int PetBreedingStartFailedComposer = 2621; // PRODUCTION-201611291003-338511768 public final static int DailyQuestComposer = 1878; // PRODUCTION-201611291003-338511768 - public final static int NewNavigatorRoomEventComposer = 1840; // PRODUCTION-201611291003-338511768 public final static int HotelViewHideCommunityVoteButtonComposer = 1435; // PRODUCTION-201611291003-338511768 public final static int CatalogSearchResultComposer = 3388; // PRODUCTION-201611291003-338511768 public final static int FriendFindingRoomComposer = 1210; // PRODUCTION-201611291003-338511768 public final static int QuestComposer = 230; // PRODUCTION-201611291003-338511768 public final static int ModToolSanctionDataComposer = 2782; // PRODUCTION-201611291003-338511768 - public final static int RoomEventMessageComposer = 2274; + public final static int RoomEventMessageComposer = 1840; public final static int JukeBoxMySongsComposer = 2602; // PRODUCTION-201611291003-338511768 diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java index aacf54cb..baff726f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorEventCategoriesComposer.java @@ -1,47 +1,26 @@ package com.eu.habbo.messages.outgoing.navigator; +import com.eu.habbo.habbohotel.navigation.EventCategory; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import java.util.ArrayList; +import java.util.List; + public class NewNavigatorEventCategoriesComposer extends MessageComposer { + public static List CATEGORIES = new ArrayList<>(); + @Override public ServerMessage compose() { this.response.init(Outgoing.NewNavigatorEventCategoriesComposer); - this.response.appendInt(11); - this.response.appendInt(1); - this.response.appendString("Hottest Events"); - this.response.appendBoolean(false); - this.response.appendInt(2); - this.response.appendString("Parties & Music"); - this.response.appendBoolean(true); - this.response.appendInt(3); - this.response.appendString("Role Play"); - this.response.appendBoolean(true); - this.response.appendInt(4); - this.response.appendString("Help Desk"); - this.response.appendBoolean(true); - this.response.appendInt(5); - this.response.appendString("Trading"); - this.response.appendBoolean(true); - this.response.appendInt(6); - this.response.appendString("Games"); - this.response.appendBoolean(true); - this.response.appendInt(7); - this.response.appendString("Debates & Discussions"); - this.response.appendBoolean(true); - this.response.appendInt(8); - this.response.appendString("Grand Openings"); - this.response.appendBoolean(true); - this.response.appendInt(9); - this.response.appendString("Friending"); - this.response.appendBoolean(true); - this.response.appendInt(10); - this.response.appendString("Jobs"); - this.response.appendBoolean(true); - this.response.appendInt(11); - this.response.appendString("Group Events"); - this.response.appendBoolean(true); + + this.response.appendInt(NewNavigatorEventCategoriesComposer.CATEGORIES.size()); + + for (EventCategory category : NewNavigatorEventCategoriesComposer.CATEGORIES) { + category.serialize(this.response); + } + return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java index e82a8055..12403e90 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomPromotionMessageComposer.java @@ -1,5 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.promotions; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomPromotion; import com.eu.habbo.messages.ServerMessage; @@ -21,37 +22,29 @@ public class RoomPromotionMessageComposer extends MessageComposer { this.response.init(Outgoing.RoomEventMessageComposer); if (this.room == null || this.roomPromotion == null) { - this.response.appendInt(-1); - this.response.appendInt(-1); - this.response.appendString(""); - this.response.appendInt(0); this.response.appendInt(0); - this.response.appendString(""); - this.response.appendString(""); - this.response.appendInt(0); - this.response.appendInt(0); this.response.appendInt(0); } else { - this.response.appendInt(this.room.getId()); + this.response.appendInt(this.room.getId()); // promotion id this.response.appendInt(this.room.getOwnerId()); this.response.appendString(this.room.getOwnerName()); - this.response.appendInt(1); - this.response.appendInt(1); + this.response.appendInt(this.room.getId()); // room id + this.response.appendInt(1); // "type" this.response.appendString(this.roomPromotion.getTitle()); this.response.appendString(this.roomPromotion.getDescription()); - this.response.appendInt(0); - this.response.appendInt(0); - this.response.appendInt(0); + this.response.appendInt((Emulator.getIntUnixTimestamp() - this.roomPromotion.getStartTimestamp()) / 60); // minutes since starting + this.response.appendInt((this.roomPromotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); // minutes until end + this.response.appendInt(this.roomPromotion.getCategory()); // category } return this.response; diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 306fc1ff..92c636d2 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionRoller; import com.eu.habbo.habbohotel.items.interactions.games.football.InteractionFootballGate; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.modtool.WordFilter; +import com.eu.habbo.habbohotel.navigation.EventCategory; import com.eu.habbo.habbohotel.navigation.NavigatorManager; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboInventory; @@ -28,6 +29,7 @@ import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent; import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent; import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent; import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; +import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesComposer; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; @@ -132,12 +134,20 @@ public class PluginManager { CameraPurchaseEvent.CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points", 5); CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 0); + NewNavigatorEventCategoriesComposer.CATEGORIES.clear(); + for (String category : Emulator.getConfig().getValue("navigator.eventcategories", "").split(";")) { + try { + NewNavigatorEventCategoriesComposer.CATEGORIES.add(new EventCategory(category)); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (Emulator.isReady) { Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPointsScheduler().reloadConfig(); Emulator.getGameEnvironment().getPixelScheduler().reloadConfig(); Emulator.getGameEnvironment().getGotwPointsScheduler().reloadConfig(); - } } From 97f4dd17e1c639517f6beefd34c2e6db6c720722 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 20:46:47 +0200 Subject: [PATCH 051/153] Undo: uncommented RCON server --- 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 b73fb65f..6999051a 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -118,13 +118,13 @@ public final class Emulator { Emulator.texts = new TextsManager(); new CleanerThread(); Emulator.gameServer = new GameServer(getConfig().getValue("game.host", "127.0.0.1"), getConfig().getInt("game.port", 30000)); - //Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); + Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); Emulator.gameEnvironment = new GameEnvironment(); Emulator.gameEnvironment.load(); Emulator.gameServer.initializePipeline(); Emulator.gameServer.connect(); - //Emulator.rconServer.initializePipeline(); - //Emulator.rconServer.connect(); + Emulator.rconServer.initializePipeline(); + Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); From 22926bf0b4765929b440c018ab03746ff4385199 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 21:02:22 +0200 Subject: [PATCH 052/153] Fix group forums --- .../eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java | 2 +- .../incoming/guilds/forums/GuildForumModerateMessageEvent.java | 2 ++ .../incoming/guilds/forums/GuildForumModerateThreadEvent.java | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java index f1f05529..01f6792c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java @@ -192,7 +192,7 @@ public class ForumThreadComment implements Runnable, ISerialize { if (!this.needsUpdate) return; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments` SET `state` = ?, `admin_id` = ? WHERE `id` = ?;")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE guilds_forums_comments SET `state` = ?, `admin_id` = ? WHERE `id` = ?")) { statement.setInt(1, this.state.getStateId()); statement.setInt(2, this.adminId); statement.setInt(3, this.commentId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java index c156a9af..9f8ab11f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java @@ -60,6 +60,8 @@ public class GuildForumModerateMessageEvent extends MessageHandler { comment.setAdminId(this.client.getHabbo().getHabboInfo().getId()); this.client.sendResponse(new PostUpdateMessageComposer(guild.getId(), thread.getThreadId(), comment)); + Emulator.getThreading().run(comment); + switch (state) { case 10: case 20: diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java index 1aaea3d6..dbb55393 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java @@ -51,6 +51,8 @@ public class GuildForumModerateThreadEvent extends MessageHandler { thread.setState(ForumThreadState.fromValue(state)); thread.setAdminId(this.client.getHabbo().getHabboInfo().getId()); + Emulator.getThreading().run(thread); + switch (state) { case 10: case 20: From 8570108d9881dcb18adf5b4a6577e0ed1b8cba28 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 21:24:29 +0200 Subject: [PATCH 053/153] Fix guild info sending (closes #328) --- .../habbo/habbohotel/guilds/GuildManager.java | 6 +++--- .../eu/habbo/habbohotel/guilds/GuildMember.java | 8 ++++++++ .../guilds/GuildMembershipStatus.java | 17 +++++++++++++++++ .../eu/habbo/habbohotel/guilds/GuildState.java | 6 ++++-- .../incoming/guilds/RequestGuildJoinEvent.java | 2 +- .../outgoing/guilds/GuildInfoComposer.java | 15 +++++++-------- 6 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java index df8a64a8..42aff936 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -203,7 +203,7 @@ public class GuildManager { } if (userId == 0 && !error) { - if (guild.getState() == GuildState.LOCKED) { + if (guild.getState() == GuildState.EXCLUSIVE) { try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as total FROM guilds_members WHERE guild_id = ? AND level_id = 3")) { statement.setInt(1, guild.getId()); try (ResultSet set = statement.executeQuery()) { @@ -236,7 +236,7 @@ public class GuildManager { statement.setInt(1, guild.getId()); statement.setInt(2, client.getHabbo().getHabboInfo().getId()); statement.setInt(3, Emulator.getIntUnixTimestamp()); - statement.setInt(4, guild.getState() == GuildState.LOCKED ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type); + statement.setInt(4, guild.getState() == GuildState.EXCLUSIVE ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type); statement.execute(); } } @@ -251,7 +251,7 @@ public class GuildManager { } if (userId == 0 && !error) { - if (guild.getState() == GuildState.LOCKED) + if (guild.getState() == GuildState.EXCLUSIVE) guild.increaseRequestCount(); else { guild.increaseMemberCount(); diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java index 87f4cdc7..173bed2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java @@ -62,4 +62,12 @@ public class GuildMember implements Comparable { public int compareTo(Object o) { return 0; } + + public GuildMembershipStatus getMembershipStatus() { + if (this.rank == GuildRank.DELETED) return GuildMembershipStatus.NOT_MEMBER; + if (this.rank == GuildRank.OWNER || this.rank == GuildRank.ADMIN || this.rank == GuildRank.MEMBER) return GuildMembershipStatus.MEMBER; + if (this.rank == GuildRank.REQUESTED) return GuildMembershipStatus.PENDING; + + return GuildMembershipStatus.NOT_MEMBER; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java new file mode 100644 index 00000000..e6cb38f7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java @@ -0,0 +1,17 @@ +package com.eu.habbo.habbohotel.guilds; + +public enum GuildMembershipStatus { + NOT_MEMBER(0), + MEMBER(1), + PENDING(2); + + private int status; + + GuildMembershipStatus(int status) { + this.status = status; + } + + public int getStatus() { + return status; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java index e2a8eb60..7fcd74eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java @@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.guilds; public enum GuildState { OPEN(0), - LOCKED(1), - CLOSED(2); + EXCLUSIVE(1), + CLOSED(2), + LARGE(3), + LARGE_CLOSED(4); public final int state; diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java index bb5a5de4..811dca2c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java @@ -21,7 +21,7 @@ public class RequestGuildJoinEvent extends MessageHandler { if (guild == null) return; - if (guild.getState() == GuildState.CLOSED) { + if (guild.getState() == GuildState.CLOSED || guild.getState() == GuildState.LARGE_CLOSED) { this.client.sendResponse(new GuildJoinErrorComposer(GuildJoinErrorComposer.GROUP_CLOSED)); return; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java index 9a106a08..edfdaa08 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java @@ -3,6 +3,7 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.GuildMember; +import com.eu.habbo.habbohotel.guilds.GuildMembershipStatus; import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -36,20 +37,18 @@ public class GuildInfoComposer extends MessageComposer { this.response.appendString(this.guild.getBadge()); this.response.appendInt(this.guild.getRoomId()); this.response.appendString(this.guild.getRoomName()); - //this.response.appendInt(this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() ? 3 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) || this.member.getRank().equals(GuildRank.ADMIN) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : 0)))); - this.response.appendInt(adminPermissions ? 4 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : (this.member.getRank().equals(GuildRank.ADMIN) ? 3 : (this.member.getRank().equals(GuildRank.OWNER) ? 4 : 0)))))); - this.response.appendInt(this.guild.getMemberCount()); //Member count. - this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); //favorite group + this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus()); + this.response.appendInt(this.guild.getMemberCount()); + this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); - this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.ADMIN) || - //Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.guild.getOwnerId()); + this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); this.response.appendString(this.guild.getOwnerName()); this.response.appendBoolean(this.newWindow); - this.response.appendBoolean(this.guild.getRights()); //User can place furni. + this.response.appendBoolean(this.guild.getRights()); this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count. - this.response.appendBoolean(this.guild.hasForum()); //Unknown + this.response.appendBoolean(this.guild.hasForum()); return this.response; } } From 70bc0f6bcb98ed0964a55042f24dc99de696cd05 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 21:56:59 +0200 Subject: [PATCH 054/153] Ensure bot z position saving & fix bots with multiheight (closes #333) --- .../interactions/InteractionMultiHeight.java | 24 +++++++++++-------- .../com/eu/habbo/habbohotel/rooms/Room.java | 1 + .../eu/habbo/habbohotel/rooms/RoomUnit.java | 8 +++++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java index dead68c8..efce0c5a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.items.interactions; +import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.*; @@ -16,6 +17,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; public class InteractionMultiHeight extends HabboItem { public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { @@ -74,26 +77,27 @@ public class InteractionMultiHeight extends HabboItem { } if (this.isWalkable()) { - THashSet habbos = room.getHabbosOnItem(this); - THashSet updatedUnits = new THashSet<>(); - for (Habbo habbo : habbos) { - if (habbo.getRoomUnit() == null) - continue; + List unitsOnItem = new ArrayList<>(); + unitsOnItem.addAll(room.getHabbosOnItem(this).stream().map(Habbo::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList())); + unitsOnItem.addAll(room.getBotsOnItem(this).stream().map(Bot::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList())); - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) + THashSet updatedUnits = new THashSet<>(); + for (RoomUnit unit : unitsOnItem) { + if (unit.hasStatus(RoomUnitStatus.MOVE)) continue; if (this.getBaseItem().getMultiHeights().length >= 0) { if (this.getBaseItem().allowSit()) { - habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + ""); + unit.setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + ""); } else { - habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); - habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getZ()); + unit.setZ(unit.getCurrentLocation().getStackHeight()); + unit.setPreviousLocationZ(unit.getZ()); } } - updatedUnits.add(habbo.getRoomUnit()); + updatedUnits.add(unit); } + room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose()); } } 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 708cfa12..49f5c894 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -466,6 +466,7 @@ public class Room implements Comparable, ISerialize, Runnable { b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); } else { b.getRoomUnit().setZ(set.getDouble("z")); + b.getRoomUnit().setPreviousLocationZ(set.getDouble("z")); b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); } b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 79ba7fab..d4c71610 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.pets.Pet; @@ -391,6 +392,13 @@ public class RoomUnit { public void setZ(double z) { this.z = z; + + if (this.room != null) { + Bot bot = this.room.getBot(this); + if (bot != null) { + bot.needsUpdate(true); + } + } } public boolean isInRoom() { From 913ca752bada12018601f32e42ae8267680c7a7e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 22:08:25 +0200 Subject: [PATCH 055/153] Clean up guild forums & ensure thread list is updated --- .../forums/GuildForumModerateThreadEvent.java | 4 ++- .../forums/GuildForumThreadUpdateEvent.java | 19 ++++++++++- .../forums/ThreadUpdatedMessageComposer.java | 32 +++---------------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java index dbb55393..6fdea270 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java @@ -10,6 +10,7 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadMessagesComposer; +import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; @@ -51,7 +52,7 @@ public class GuildForumModerateThreadEvent extends MessageHandler { thread.setState(ForumThreadState.fromValue(state)); thread.setAdminId(this.client.getHabbo().getHabboInfo().getId()); - Emulator.getThreading().run(thread); + thread.run(); switch (state) { case 10: @@ -64,5 +65,6 @@ public class GuildForumModerateThreadEvent extends MessageHandler { } this.client.sendResponse(new GuildForumThreadMessagesComposer(thread)); + this.client.sendResponse(new GuildForumThreadsComposer(guild, 0)); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java index e2004257..a73b9b27 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadUpdateEvent.java @@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.habbohotel.guilds.SettingsState; import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumThreadsComposer; import com.eu.habbo.messages.outgoing.guilds.forums.ThreadUpdatedMessageComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; @@ -42,9 +44,24 @@ public class GuildForumThreadUpdateEvent extends MessageHandler { return; } + boolean pinChanged = isPinned != thread.isPinned(); + if (pinChanged) { + this.client.sendResponse(new BubbleAlertComposer(isPinned ? BubbleAlertKeys.FORUMS_THREAD_PINNED.key : BubbleAlertKeys.FORUMS_THREAD_UNPINNED.key).compose()); + } + + if (isLocked != thread.isLocked()) { + this.client.sendResponse(new BubbleAlertComposer(isLocked ? BubbleAlertKeys.FORUMS_THREAD_LOCKED.key : BubbleAlertKeys.FORUMS_THREAD_UNLOCKED.key).compose()); + } + + thread.setPinned(isPinned); + thread.setLocked(isLocked); + + thread.run(); + + this.client.sendResponse(new ThreadUpdatedMessageComposer(guild, thread, this.client.getHabbo(), isPinned, isLocked)); - if (isPinned) { + if (pinChanged) { this.client.sendResponse(new GuildForumThreadsComposer(guild, 0)); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java index 4d2453ef..4476859a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/ThreadUpdatedMessageComposer.java @@ -1,15 +1,11 @@ package com.eu.habbo.messages.outgoing.guilds.forums; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; -import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.habbohotel.guilds.forums.ForumThread; 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 com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; -import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; public class ThreadUpdatedMessageComposer extends MessageComposer { @@ -33,30 +29,10 @@ public class ThreadUpdatedMessageComposer extends MessageComposer { @Override public ServerMessage compose() { - if (isPinned != thread.isPinned()) { - this.habbo.getClient().sendResponse(new BubbleAlertComposer(isPinned ? BubbleAlertKeys.FORUMS_THREAD_PINNED.key : BubbleAlertKeys.FORUMS_THREAD_UNPINNED.key).compose()); - } + this.response.init(Outgoing.ThreadUpdateMessageComposer); + this.response.appendInt(this.thread.getGuildId()); + this.thread.serialize(this.response); - if (isLocked != thread.isLocked()) { - this.habbo.getClient().sendResponse(new BubbleAlertComposer(isLocked ? BubbleAlertKeys.FORUMS_THREAD_LOCKED.key : BubbleAlertKeys.FORUMS_THREAD_UNLOCKED.key).compose()); - } - - if (this.habbo.getHabboInfo().getId() != guild.getOwnerId() || - guild.canModForum().state == 2 && (Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.OWNER - || Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo).getRank() == GuildRank.ADMIN) - || this.habbo.hasPermission("acc_modtool_ticket_q")) { - this.thread.setPinned(isPinned); - this.thread.setLocked(isLocked); - - Emulator.getThreading().run(this.thread); - - this.response.init(Outgoing.ThreadUpdateMessageComposer); - this.response.appendInt(this.thread.getGuildId()); - this.thread.serialize(this.response); - - return this.response; - } - - return null; + return this.response; } } \ No newline at end of file From 9b062bd7600f08518551747321d5b95a2591a709 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 22:38:41 +0200 Subject: [PATCH 056/153] Fix #331 --- .../items/interactions/InteractionGate.java | 4 ++-- .../items/interactions/InteractionPuzzleBox.java | 2 ++ .../items/interactions/InteractionTeleport.java | 10 +++++++--- .../interactions/InteractionVendingMachine.java | 2 ++ .../com/eu/habbo/habbohotel/users/HabboItem.java | 14 +++++++++++--- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java index 14e38794..5c0b3422 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java @@ -38,8 +38,6 @@ public class InteractionGate extends HabboItem { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE); if (client != null && !room.hasRights(client.getHabbo()) && !isWired) return; @@ -54,6 +52,8 @@ public class InteractionGate extends HabboItem { room.updateTile(room.getLayout().getTile(this.getX(), this.getY())); this.needsUpdate(true); room.updateItemState(this); + + super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); } public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 355acb8b..899dcaba 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -80,6 +80,8 @@ public class InteractionPuzzleBox extends HabboItem { room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose()); room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); this.needsUpdate(true); + + super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); } @Override 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 0720fba6..8c20fa5b 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 @@ -83,6 +83,12 @@ public class InteractionTeleport extends HabboItem { if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { startTeleport(room, habbo); walkable = true; + + try { + super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); + } catch (Exception e) { + e.printStackTrace(); + } } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { // set state 1 and walk on item this.roomUnitID = unit.getId(); @@ -133,9 +139,7 @@ public class InteractionTeleport extends HabboItem { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - - if (room != null && client != null && objects.length <= 1) { + if (room != null && client != null && objects != null && objects.length <= 1) { tryTeleport(client, room); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 19a5c52b..b7a77a94 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -62,6 +62,8 @@ public class InteractionVendingMachine extends HabboItem { room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + + super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); } } else { if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) { diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index ec5960a8..4fe8a220 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.IEventTriggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; +import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -20,7 +21,6 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; -import com.eu.habbo.util.figure.FigureUtil; import gnu.trove.set.hash.THashSet; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.math3.util.Pair; @@ -34,6 +34,13 @@ import java.util.Arrays; import java.util.List; public abstract class HabboItem implements Runnable, IEventTriggers { + private static Class[] TOGGLING_INTERACTIONS = new Class[]{ + InteractionGameTimer.class, + InteractionWired.class, + InteractionWiredHighscore.class, + InteractionMultiHeight.class + }; + private int id; private int userId; private int roomId; @@ -283,8 +290,9 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } } - - WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this}); + if ((this.getBaseItem().getStateCount() > 1 && !(this instanceof InteractionDice)) || Arrays.asList(HabboItem.TOGGLING_INTERACTIONS).contains(this.getClass()) || (objects != null && objects.length == 1 && objects[0].equals("TOGGLE_OVERRIDE"))) { + WiredHandler.handle(WiredTriggerType.STATE_CHANGED, client.getHabbo().getRoomUnit(), room, new Object[]{this}); + } } } From aff9e75fe1a24dc3b68b076fc07f0006a383f60c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 23:02:53 +0200 Subject: [PATCH 057/153] Fix bot z position saving and sending --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 4 ++-- .../java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 2 +- .../outgoing/rooms/users/RoomUserStatusComposer.java | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 49f5c894..652b5cfd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -764,7 +764,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.getRoomUnit().setPreviousLocationZ(topItem.getZ()); bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation())); } else { - bot.getRoomUnit().setZ(topItem.getZ() + topItem.getBaseItem().getHeight()); + bot.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem)); if (topItem.getBaseItem().allowLay()) { bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + ""); @@ -772,6 +772,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } else { bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); + bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); } roomUnits.add(bot.getRoomUnit()); @@ -1604,7 +1605,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.dance(unit, DanceType.NONE); //int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z; unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + ""); - unit.setPreviousLocationZ(topItem.getZ()); unit.setZ(topItem.getZ()); unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); unit.sitUpdate = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 9157886e..60c67a59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -770,7 +770,7 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit())); } - habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit())); + habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit(), bot.getRoomUnit().getZ())); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java index 652511e8..28f89597 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java @@ -14,12 +14,18 @@ import java.util.Map; public class RoomUserStatusComposer extends MessageComposer { private Collection habbos; private THashSet roomUnits; + private double overrideZ = -1; public RoomUserStatusComposer(RoomUnit roomUnit) { this.roomUnits = new THashSet<>(); this.roomUnits.add(roomUnit); } + public RoomUserStatusComposer(RoomUnit roomUnit, double overrideZ) { + this(roomUnit); + this.overrideZ = overrideZ; + } + public RoomUserStatusComposer(THashSet roomUnits, boolean value) { this.roomUnits = roomUnits; } @@ -37,7 +43,7 @@ public class RoomUserStatusComposer extends MessageComposer { this.response.appendInt(roomUnit.getId()); this.response.appendInt(roomUnit.getPreviousLocation().x); this.response.appendInt(roomUnit.getPreviousLocation().y); - this.response.appendString(roomUnit.getPreviousLocationZ() + ""); + this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + ""); this.response.appendInt(roomUnit.getHeadRotation().getValue()); From ae9e6cfa6250e20ef7f0b0abbebb86bb5da11523 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 23:48:34 +0200 Subject: [PATCH 058/153] Fix puzzle boxes going through the wall (closes #340) --- .../habbohotel/items/interactions/InteractionPuzzleBox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 899dcaba..ca836501 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -62,7 +62,7 @@ public class InteractionPuzzleBox extends HabboItem { RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue()); - if (tile == null || room.hasHabbosAt(tile.x, tile.y)) { + if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.x, tile.y)) { return; } From 1e24df5b6159a56566825332e56a37f4ec636b16 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 00:11:47 +0200 Subject: [PATCH 059/153] Use batch item update packet to sync banzai tile flickering (closes #339) --- src/main/java/com/eu/habbo/Emulator.java | 6 +++--- .../outgoing/rooms/items/ItemsDataUpdateComposer.java | 8 ++++++-- .../threading/runnables/BattleBanzaiTilesFlicker.java | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 6999051a..b73fb65f 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -118,13 +118,13 @@ public final class Emulator { Emulator.texts = new TextsManager(); new CleanerThread(); Emulator.gameServer = new GameServer(getConfig().getValue("game.host", "127.0.0.1"), getConfig().getInt("game.port", 30000)); - Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); + //Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); Emulator.gameEnvironment = new GameEnvironment(); Emulator.gameEnvironment.load(); Emulator.gameServer.initializePipeline(); Emulator.gameServer.connect(); - Emulator.rconServer.initializePipeline(); - Emulator.rconServer.connect(); + //Emulator.rconServer.initializePipeline(); + //Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java index aa5244e8..f9c18df7 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java @@ -6,11 +6,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import java.util.List; +import java.util.Set; public class ItemsDataUpdateComposer extends MessageComposer { - private final List items; + private final Set items; - public ItemsDataUpdateComposer(List items) { + public ItemsDataUpdateComposer(Set items) { this.items = items; } @@ -18,9 +19,12 @@ public class ItemsDataUpdateComposer extends MessageComposer { public ServerMessage compose() { this.response.init(Outgoing.ItemsDataUpdateComposer); this.response.appendInt(this.items.size()); + for (HabboItem item : this.items) { + this.response.appendInt(item.getId()); item.serializeExtradata(this.response); } + return this.response; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java index 345c45be..77eb02ef 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BattleBanzaiTilesFlicker.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.outgoing.rooms.items.ItemsDataUpdateComposer; import gnu.trove.set.hash.THashSet; public class BattleBanzaiTilesFlicker implements Runnable { @@ -36,9 +37,10 @@ public class BattleBanzaiTilesFlicker implements Runnable { for (HabboItem item : this.items) { item.setExtradata(state + ""); - this.room.updateItem(item); } + this.room.sendComposer(new ItemsDataUpdateComposer(this.items).compose()); + if (this.count == 5) { for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) { item.setExtradata("0"); From 6b0043317a656ec2fa100a40311a0aa3b6a0bfc9 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 00:12:47 +0200 Subject: [PATCH 060/153] Undo: RCON commented out (again) --- src/main/java/com/eu/habbo/Emulator.java | 6 +++--- .../outgoing/rooms/items/ItemsDataUpdateComposer.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index b73fb65f..6999051a 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -118,13 +118,13 @@ public final class Emulator { Emulator.texts = new TextsManager(); new CleanerThread(); Emulator.gameServer = new GameServer(getConfig().getValue("game.host", "127.0.0.1"), getConfig().getInt("game.port", 30000)); - //Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); + Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001)); Emulator.gameEnvironment = new GameEnvironment(); Emulator.gameEnvironment.load(); Emulator.gameServer.initializePipeline(); Emulator.gameServer.connect(); - //Emulator.rconServer.initializePipeline(); - //Emulator.rconServer.connect(); + Emulator.rconServer.initializePipeline(); + Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java index f9c18df7..0dddc403 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/ItemsDataUpdateComposer.java @@ -24,7 +24,7 @@ public class ItemsDataUpdateComposer extends MessageComposer { this.response.appendInt(item.getId()); item.serializeExtradata(this.response); } - + return this.response; } } \ No newline at end of file From a5f4df51acb755fd3c995314662165d5f1c837ea Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 00:17:31 +0200 Subject: [PATCH 061/153] Give badge when purchasing a room ad --- sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql | 4 +++- .../rooms/promotions/BuyRoomPromotionEvent.java | 14 ++++++++++++-- .../java/com/eu/habbo/plugin/PluginManager.java | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql index 26b22d5d..f766bc3a 100644 --- a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql +++ b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql @@ -7,4 +7,6 @@ ADD COLUMN `start_timestamp` int(11) NOT NULL DEFAULT -1 AFTER `end_timestamp`; ALTER TABLE `room_promotions` ADD COLUMN `category` int(11) NOT NULL DEFAULT 0 AFTER `start_timestamp`; -INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('navigator.eventcategories', '1,Hottest Events,false;2,Parties & Music,true;3,Role Play,true;4,Help Desk,true;5,Trading,true;6,Games,true;7,Debates & Discussions,true;8,Grand Openings,true;9,Friending,true;10,Jobs,true;11,Group Events,true'); \ No newline at end of file +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('navigator.eventcategories', '1,Hottest Events,false;2,Parties & Music,true;3,Role Play,true;4,Help Desk,true;5,Trading,true;6,Games,true;7,Debates & Discussions,true;8,Grand Openings,true;9,Friending,true;10,Jobs,true;11,Group Events,true'); + +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.promotion.badge', 'RADZZ'); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java index dc5278c5..2fa40246 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/BuyRoomPromotionEvent.java @@ -11,6 +11,8 @@ import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesCompo import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; public class BuyRoomPromotionEvent extends MessageHandler { + public static String ROOM_PROMOTION_BADGE = "RADZZ"; + @Override public void handle() throws Exception { int pageId = this.packet.readInt(); @@ -43,12 +45,20 @@ public class BuyRoomPromotionEvent extends MessageHandler { } if (room.isPromoted()) { - if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) + if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) { this.client.getHabbo().giveCredits(-item.getCredits()); - if (!this.client.getHabbo().hasPermission("acc_infinite_points")) + } + + if (!this.client.getHabbo().hasPermission("acc_infinite_points")) { this.client.getHabbo().givePoints(item.getPointsType(), -item.getPoints()); + } + this.client.sendResponse(new PurchaseOKComposer()); room.sendComposer(new RoomPromotionMessageComposer(room, room.getPromotion()).compose()); + + if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE)) { + this.client.getHabbo().addBadge(BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE); + } } else { this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 92c636d2..2a6c45f9 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -27,6 +27,7 @@ import com.eu.habbo.messages.incoming.camera.CameraPublishToWebEvent; import com.eu.habbo.messages.incoming.camera.CameraPurchaseEvent; import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent; import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent; +import com.eu.habbo.messages.incoming.rooms.promotions.BuyRoomPromotionEvent; import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent; import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesComposer; @@ -134,6 +135,8 @@ public class PluginManager { CameraPurchaseEvent.CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points", 5); CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 0); + BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE = Emulator.getConfig().getValue("room.promotion.badge", "RADZZ"); + NewNavigatorEventCategoriesComposer.CATEGORIES.clear(); for (String category : Emulator.getConfig().getValue("navigator.eventcategories", "").split(";")) { try { From be6b206211d895948e984384cd488f54fb52dd52 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 00:18:46 +0200 Subject: [PATCH 062/153] Ensure that potential adjacent tiles are not null (puzzlebox) --- .../habbohotel/items/interactions/InteractionPuzzleBox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index ca836501..6a2bfe80 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -53,7 +53,7 @@ public class InteractionPuzzleBox extends HabboItem { room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.WEST.getValue()) } ) - .filter(t -> t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) + .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) .min(Comparator.comparingDouble(a -> a.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))); nearestTile.ifPresent(roomTile -> client.getHabbo().getRoomUnit().setGoalLocation(roomTile)); From 4f351b04ee52d94de098ada6f5fcfa6b0f5545c9 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 01:06:53 +0200 Subject: [PATCH 063/153] Implement most viewed guild forums --- sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql | 8 +++ .../habbo/habbohotel/guilds/GuildManager.java | 58 +++++++++++++++++-- .../habbohotel/guilds/forums/ForumView.java | 34 +++++++++++ .../guilds/forums/GuildForumDataEvent.java | 4 ++ .../guilds/forums/GuildForumListEvent.java | 11 ++-- .../guilds/forums/GuildForumListComposer.java | 5 +- 6 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java diff --git a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql index f766bc3a..66bbf938 100644 --- a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql +++ b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql @@ -10,3 +10,11 @@ ADD COLUMN `category` int(11) NOT NULL DEFAULT 0 AFTER `start_timestamp`; INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('navigator.eventcategories', '1,Hottest Events,false;2,Parties & Music,true;3,Role Play,true;4,Help Desk,true;5,Trading,true;6,Games,true;7,Debates & Discussions,true;8,Grand Openings,true;9,Friending,true;10,Jobs,true;11,Group Events,true'); INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.promotion.badge', 'RADZZ'); + +CREATE TABLE `guild_forum_views` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) NOT NULL, + `guild_id` int(11) NOT NULL, + `timestamp` int(11) NOT NULL, + PRIMARY KEY (`id`) +); diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java index 42aff936..71a017aa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.guilds; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.guilds.forums.ForumView; import com.eu.habbo.habbohotel.items.interactions.InteractionGuildFurni; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; @@ -14,10 +15,8 @@ import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; import java.sql.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.NoSuchElementException; +import java.util.*; +import java.util.stream.Collectors; public class GuildManager { @@ -25,12 +24,16 @@ public class GuildManager { private final TIntObjectMap guilds; + private final THashSet views = new THashSet<>(); + public GuildManager() { long millis = System.currentTimeMillis(); this.guildParts = new THashMap>(); this.guilds = TCollections.synchronizedMap(new TIntObjectHashMap()); this.loadGuildParts(); + this.loadGuildViews(); + Emulator.getLogging().logStart("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -53,6 +56,19 @@ public class GuildManager { } } + public void loadGuildViews() { + this.views.clear(); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); + Statement statement = connection.createStatement(); + ResultSet set = statement.executeQuery("SELECT * FROM guild_forum_views")) { + while (set.next()) { + this.views.add(new ForumView(set)); + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } public Guild createGuild(Habbo habbo, int roomId, String roomName, String name, String description, String badge, int colorOne, int colorTwo) { Guild guild = new Guild(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), roomId, roomName, name, description, colorOne, colorTwo, badge); @@ -594,4 +610,38 @@ public class GuildManager { } Emulator.getLogging().logShutdownLine("Guild Manager -> Disposed!"); } + + public boolean hasViewedForum(int userId, int guildId) { + return this.views.stream() + .anyMatch(v -> v.getUserId() == userId && v.getGuildId() == guildId && v.getTimestamp() > (Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60)); + } + + public void addView(int userId, int guildId) { + ForumView view = new ForumView(userId, guildId, Emulator.getIntUnixTimestamp()); + + this.views.add(view); + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `guild_forum_views`(`user_id`, `guild_id`, `timestamp`) VALUES (?, ?, ?)")) { + statement.setInt(1, view.getUserId()); + statement.setInt(2, view.getGuildId()); + statement.setInt(3, view.getTimestamp()); + + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + public Set getMostViewed() { + return this.views.stream() + .filter(v -> v.getTimestamp() > (Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60)) + .collect(Collectors.groupingBy(ForumView::getGuildId)) + .entrySet() + .stream() + .sorted(Comparator.comparingInt((Map.Entry> a) -> a.getValue().size())) + .map(k -> this.getGuild(k.getKey())) + .filter(g -> g != null && g.canReadForum() == SettingsState.EVERYONE) + .limit(100) + .collect(Collectors.toSet()); + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java new file mode 100644 index 00000000..c1b2569e --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumView.java @@ -0,0 +1,34 @@ +package com.eu.habbo.habbohotel.guilds.forums; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ForumView { + private final int userId; + private final int guildId; + private final int timestamp; + + public ForumView(int userId, int guildId, int timestamp) { + this.userId = userId; + this.guildId = guildId; + this.timestamp = timestamp; + } + + public ForumView(ResultSet set) throws SQLException { + this.userId = set.getInt("user_id"); + this.guildId = set.getInt("guild_id"); + this.timestamp = set.getInt("timestamp"); + } + + public int getUserId() { + return userId; + } + + public int getGuildId() { + return guildId; + } + + public int getTimestamp() { + return timestamp; + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java index 88fec7ab..ab78d2c0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumDataEvent.java @@ -16,5 +16,9 @@ public class GuildForumDataEvent extends MessageHandler { return; this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo())); + + if (!Emulator.getGameEnvironment().getGuildManager().hasViewedForum(this.client.getHabbo().getHabboInfo().getId(), guildId)) { + Emulator.getGameEnvironment().getGuildManager().addView(this.client.getHabbo().getHabboInfo().getId(), guildId); + } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java index a47a52bc..9dc377e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java @@ -11,6 +11,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Set; public class GuildForumListEvent extends MessageHandler { @Override @@ -19,14 +20,14 @@ public class GuildForumListEvent extends MessageHandler { int offset = this.packet.readInt(); int amount = this.packet.readInt(); - THashSet guilds = null; + Set guilds = null; switch (mode) { case 0: // most active - guilds = getPopularForums(); + guilds = getActiveForums(); break; case 1: // most viewed - guilds = getPopularForums(); + guilds = Emulator.getGameEnvironment().getGuildManager().getMostViewed(); break; case 2: // my groups @@ -39,14 +40,16 @@ public class GuildForumListEvent extends MessageHandler { } } - private THashSet getPopularForums() { + private THashSet getActiveForums() { THashSet guilds = new THashSet(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT `guilds`.`id`, SUM(`guilds_forums_threads`.`posts_count`) AS `post_count` " + "FROM `guilds_forums_threads` " + "LEFT JOIN `guilds` ON `guilds`.`id` = `guilds_forums_threads`.`guild_id` " + + "WHERE `guilds`.`read_forum` = 'EVERYONE' AND `guilds_forums_threads`.`created_at` > ? " + "GROUP BY `guilds`.`id` " + "ORDER BY `post_count` DESC LIMIT 100")) { + statement.setInt(1, Emulator.getIntUnixTimestamp() - 7 * 24 * 60 * 60); ResultSet set = statement.executeQuery(); while (set.next()) { diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java index f3050354..4700bc13 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumListComposer.java @@ -8,14 +8,15 @@ import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; import java.util.Iterator; +import java.util.Set; public class GuildForumListComposer extends MessageComposer { - private final THashSet guilds; + private final Set guilds; private final Habbo habbo; private final int mode; private final int index; - public GuildForumListComposer(THashSet guilds, Habbo habbo, int mode, int index) { + public GuildForumListComposer(Set guilds, Habbo habbo, int mode, int index) { this.guilds = guilds; this.habbo = habbo; this.mode = mode; From e1595b7044f3754a6bdb4f0c8bd6f25dad01e3bf Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 01:36:01 +0200 Subject: [PATCH 064/153] Fix photo reporting --- sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql | 3 +++ .../eu/habbo/habbohotel/modtool/ModToolIssue.java | 9 +++++++++ .../incoming/modtool/ReportPhotoEvent.java | 14 ++++---------- .../threading/runnables/InsertModToolIssue.java | 3 ++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql index 66bbf938..c1280901 100644 --- a/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql +++ b/sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql @@ -18,3 +18,6 @@ CREATE TABLE `guild_forum_views` ( `timestamp` int(11) NOT NULL, PRIMARY KEY (`id`) ); + +ALTER TABLE `support_tickets` +ADD COLUMN `photo_item_id` int(11) NOT NULL DEFAULT -1 AFTER `comment_id`; diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java index 3d2437e0..14a0b737 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java @@ -45,6 +45,15 @@ public class ModToolIssue implements ISerialize { this.modName = set.getString("mod_username"); this.type = ModToolTicketType.values()[set.getInt("type") - 1]; this.category = set.getInt("category"); + this.groupId = set.getInt("group_id"); + this.threadId = set.getInt("thread_id"); + this.commentId = set.getInt("comment_id"); + + int photoItemId = set.getInt("photo_item_id"); + + if (photoItemId != -1) { + this.photoItem = Emulator.getGameEnvironment().getItemManager().loadHabboItem(photoItemId);; + } if (this.modId <= 0) { this.modName = ""; diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java index 04b75b4f..c929941a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java @@ -41,18 +41,12 @@ public class ReportPhotoEvent extends MessageHandler { if (item == null || !(item instanceof InteractionExternalImage)) return; - InteractionExternalImage photoItem = (InteractionExternalImage) item; + HabboInfo photoOwner = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(item.getUserId()); - String photoCreatorId = new JsonParser().parse(photoItem.getExtradata()).getAsJsonObject().get("u").getAsString(); + if (photoOwner == null) return; - if (photoCreatorId == null) return; - - HabboInfo photoCreator = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(Integer.valueOf(photoCreatorId)); - - if (photoCreator == null) return; - - ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), photoCreator.getId(), photoCreator.getUsername(), roomId, "", ModToolTicketType.PHOTO); - issue.photoItem = photoItem; + ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), photoOwner.getId(), photoOwner.getUsername(), roomId, "", ModToolTicketType.PHOTO); + issue.photoItem = item; new InsertModToolIssue(issue).run(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java index af335844..b1af7db2 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java @@ -14,7 +14,7 @@ public class InsertModToolIssue implements Runnable { @Override public void run() { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category, group_id, thread_id, comment_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category, group_id, thread_id, comment_id, photo_item_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) { statement.setInt(1, this.issue.state.getState()); statement.setInt(2, this.issue.timestamp); statement.setInt(3, this.issue.priority); @@ -27,6 +27,7 @@ public class InsertModToolIssue implements Runnable { statement.setInt(10, this.issue.groupId); statement.setInt(11, this.issue.threadId); statement.setInt(12, this.issue.commentId); + statement.setInt(13, this.issue.photoItem != null ? this.issue.photoItem.getId() : -1); statement.execute(); try (ResultSet key = statement.getGeneratedKeys()) { From ec72aa6decda55ff27af211b7d21243354631a27 Mon Sep 17 00:00:00 2001 From: David Silva Date: Mon, 27 Jan 2020 19:06:59 -0500 Subject: [PATCH 065/153] fix(ModToolSanctionInfoComposer): OoB --- .../messages/outgoing/modtool/ModToolSanctionInfoComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java index 54ae2d60..ca323066 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolSanctionInfoComposer.java @@ -38,7 +38,7 @@ public class ModToolSanctionInfoComposer extends MessageComposer { ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); ModToolSanctionItem prevItem = null; - if (modToolSanctionItems.get(modToolSanctionItems.size() - 2) != null) { + if (modToolSanctionItems.size() > 1 && modToolSanctionItems.get(modToolSanctionItems.size() - 2) != null) { prevItem = modToolSanctionItems.get(modToolSanctionItems.size() - 2); } From 8c4a44e3e7e97b7776dfdacbc2502bdbf34b8744 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 13:51:55 +0200 Subject: [PATCH 066/153] Fix #349 --- .../habbohotel/items/interactions/InteractionPuzzleBox.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 6a2bfe80..0d6b0509 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -60,6 +60,8 @@ public class InteractionPuzzleBox extends HabboItem { return; } + super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); + RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue()); if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.x, tile.y)) { @@ -80,8 +82,6 @@ public class InteractionPuzzleBox extends HabboItem { room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose()); room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); this.needsUpdate(true); - - super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); } @Override From da2e78697bd1e256b2d0893948ba714ed2b46b87 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 13:55:07 +0200 Subject: [PATCH 067/153] Match puzzlebox behaviour to Habbo --- .../items/interactions/InteractionPuzzleBox.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index 0d6b0509..ca1e4d6e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -24,9 +24,6 @@ public class InteractionPuzzleBox extends HabboItem { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - if (client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) - return; - RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY()); RoomUserRotation rotation = null; @@ -80,7 +77,11 @@ public class InteractionPuzzleBox extends HabboItem { room.updateItem(this); room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose()); - room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); + room.scheduledTasks.add(() -> { + client.getHabbo().getRoomUnit().setGoalLocation(boxLocation); + + room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation)); + }); this.needsUpdate(true); } From 42ebfad128175bb822a32052dd99c0cb9b4f05d4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 15:13:32 +0200 Subject: [PATCH 068/153] Fix moving/rotatingg furniture in the same coordinates (closes #352) --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 3 +++ 1 file changed, 3 insertions(+) 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 652b5cfd..91d0671c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4486,8 +4486,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } //Place at new position + double height = this.getStackHeight(tile.x, tile.y, false, item); + if (tile.x == item.getX() && tile.y == item.getY()) height = item.getZ(); if(height > 40d) return FurnitureMovementError.CANT_STACK; + item.setX(tile.x); item.setY(tile.y); item.setZ(height); From d3b8ee6b761288b4705c559bf4e0ddebf9cf859e Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 15:24:03 +0200 Subject: [PATCH 069/153] Speed up vending machine animation (closes #351) --- .../interactions/InteractionVendingMachine.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index b7a77a94..1ad43067 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -11,10 +11,13 @@ import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import com.eu.habbo.util.pathfinding.Rotation; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class InteractionVendingMachine extends HabboItem { public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException { @@ -74,8 +77,20 @@ public class InteractionVendingMachine extends HabboItem { } } } + + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); + + onSuccess.add(() -> Emulator.getThreading().run(() -> { + try { + this.onClick(client, room, objects); + } catch (Exception e) { + e.printStackTrace(); + } + }, 150)); + client.getHabbo().getRoomUnit().setGoalLocation(tile); - Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510); + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail)); } } } From ccf47ea139807742efebe304ae51eb7a9e9f746f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 28 Jan 2020 16:09:59 +0200 Subject: [PATCH 070/153] Fix vending machine behaviour --- .../items/interactions/InteractionVendingMachine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 1ad43067..ed20e804 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -50,8 +50,8 @@ public class InteractionVendingMachine extends HabboItem { if (tile != null) { if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) { - room.updateHabbo(client.getHabbo()); - if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { + if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) { + room.updateHabbo(client.getHabbo()); client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]); client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); From db71cd840671acacfd6719297887f5cf804d5c25 Mon Sep 17 00:00:00 2001 From: Dank074 Date: Wed, 29 Jan 2020 22:03:00 -0600 Subject: [PATCH 071/153] rank effects added to EffectsComponent in inventory --- .../habbo/habbohotel/users/HabboManager.java | 9 ++++++++- .../users/inventory/EffectsComponent.java | 20 ++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java index 0a1a6b00..27adcc59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolBan; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Rank; +import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; @@ -246,7 +247,9 @@ public class HabboManager { Rank oldRank = habbo.getHabboInfo().getRank(); if (!oldRank.getBadge().isEmpty()) { habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge())); - //BadgesComponent.deleteBadge(userId, oldRank.getBadge()); // unnecessary as Habbo.deleteBadge does this + } + if(oldRank.getRoomEffect() > 0) { + habbo.getInventory().getEffectsComponent().effects.remove(oldRank.getRoomEffect()); } habbo.getHabboInfo().setRank(newRank); @@ -255,6 +258,10 @@ public class HabboManager { habbo.addBadge(newRank.getBadge()); } + if(newRank.getRoomEffect() > 0) { + habbo.getInventory().getEffectsComponent().createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect()); + } + habbo.getClient().sendResponse(new UserPermissionsComposer(habbo)); habbo.getClient().sendResponse(new UserPerksComposer(habbo)); 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 b0da325b..6448e23a 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 @@ -31,6 +31,8 @@ public class EffectsComponent { } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } + if(habbo.getHabboInfo().getRank().getRoomEffect() > 0) + this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect()); } public HabboEffect createEffect(int effectId) { @@ -58,6 +60,15 @@ public class EffectsComponent { return effect; } + public HabboEffect createRankEffect(int effectId) { + HabboEffect rankEffect = new HabboEffect(effectId, habbo.getHabboInfo().getId()); + rankEffect.duration = 0; + rankEffect.isRankEnable = true; + rankEffect.activationTimestamp = Emulator.getIntUnixTimestamp(); + this.effects.put(effectId, rankEffect); + return rankEffect; + } + public void addEffect(HabboEffect effect) { this.effects.put(effect.effect, effect); @@ -67,9 +78,8 @@ public class EffectsComponent { public void dispose() { synchronized (this.effects) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET duration = ?, activation_timestamp = ?, total = ? WHERE user_id = ? AND effect = ?")) { - this.effects.forEachValue(new TObjectProcedure() { - @Override - public boolean execute(HabboEffect effect) { + this.effects.forEachValue(effect -> { + if(!effect.isRankEnable) { try { statement.setInt(1, effect.duration); statement.setInt(2, effect.activationTimestamp); @@ -80,9 +90,8 @@ public class EffectsComponent { } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } - - return true; } + return true; }); statement.executeBatch(); @@ -145,6 +154,7 @@ public class EffectsComponent { public int activationTimestamp = -1; public int total = 1; public boolean enabled = false; + public boolean isRankEnable = false; public HabboEffect(ResultSet set) throws SQLException { this.effect = set.getInt("effect"); From 1527fe5593973185f0a5acd76d393bba26f61251 Mon Sep 17 00:00:00 2001 From: Dank074 Date: Wed, 29 Jan 2020 22:49:35 -0600 Subject: [PATCH 072/153] rank effect should not be applied from RoomManager, apply it from EffectsComponent instead --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 5 ----- .../habbo/habbohotel/users/inventory/EffectsComponent.java | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 60c67a59..b0512576 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -747,11 +747,6 @@ public class RoomManager { } int effect = habbo.getInventory().getEffectsComponent().activatedEffect; - - if (effect == 0) { - effect = habbo.getHabboInfo().getRank().getRoomEffect(); - } - room.giveEffect(habbo.getRoomUnit(), effect, -1); } 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 6448e23a..b1e50d72 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 @@ -65,7 +65,9 @@ public class EffectsComponent { rankEffect.duration = 0; rankEffect.isRankEnable = true; rankEffect.activationTimestamp = Emulator.getIntUnixTimestamp(); + rankEffect.enabled = true; this.effects.put(effectId, rankEffect); + this.activatedEffect = effectId; // enabled by default return rankEffect; } From fcccd70eb310b96d8cf8956b6685e24d78ccad47 Mon Sep 17 00:00:00 2001 From: skeletor Date: Thu, 30 Jan 2020 03:29:01 -0500 Subject: [PATCH 073/153] tent should not change state when clicked --- .../habbohotel/items/interactions/InteractionTent.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java index bf2d2021..7ded66c2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.items.interactions; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.Room; import java.sql.ResultSet; import java.sql.SQLException; @@ -13,4 +15,9 @@ public class InteractionTent extends InteractionDefault { public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } + + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + // do nothing + } } From 733620b9b0e4c20069316b485e12b0e59031cccf Mon Sep 17 00:00:00 2001 From: skeletor Date: Thu, 30 Jan 2020 03:29:38 -0500 Subject: [PATCH 074/153] Totem planet should only give effect to planet owner --- .../items/interactions/totems/InteractionTotemPlanet.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java index 75b48203..2c49e91c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java @@ -33,6 +33,11 @@ public class InteractionTotemPlanet extends InteractionDefault { @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if(client.getHabbo().getHabboInfo().getId() != this.getUserId()) { + super.onClick(client, room, objects); + return; + } + InteractionTotemLegs legs = null; InteractionTotemHead head = null; From 176e2121f95b85024c362251d6a3dfddb01edc6d Mon Sep 17 00:00:00 2001 From: David Silva Date: Thu, 30 Jan 2020 16:54:30 +0100 Subject: [PATCH 075/153] feat(PacketManager): enable 3500 --- src/main/java/com/eu/habbo/messages/PacketManager.java | 2 +- src/main/java/com/eu/habbo/messages/PacketManager_1006.java | 1 + src/main/java/com/eu/habbo/messages/incoming/Incoming.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index ccc54701..1a6c73a1 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -343,10 +343,10 @@ public class PacketManager { } private void registerInventory() throws Exception { - //this.registerHandler(Incoming.TestInventoryEvent, TestInventoryEvent.class); this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class); this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class); this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class); + this.registerHandler(Incoming.HotelViewInventoryEvent, RequestInventoryItemsEvent.class); this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class); } diff --git a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java index a7241c2d..6d11324f 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java @@ -228,6 +228,7 @@ public class PacketManager_1006 { this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class); this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class); this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class); + this.registerHandler(Incoming.HotelViewInventoryEvent, RequestInventoryItemsEvent.class); this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index e5cf0ba7..a38210d6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -136,7 +136,7 @@ public class Incoming { public static final int RequestAchievementsEvent = 219; public static final int GuildChangeColorsEvent = 1764; public static final int RequestInventoryBadgesEvent = 2769; - public static final int TestInventoryEvent = 3500; + public static final int HotelViewInventoryEvent = 3500; public static final int RequestPetBreedsEvent = 1756; public static final int GuildChangeBadgeEvent = 1991; public static final int ModToolBanEvent = -1; From b89e6726b1c0ec8d16e9fa19a6f0d9a8ee7ce31f Mon Sep 17 00:00:00 2001 From: skeletor Date: Fri, 31 Jan 2020 11:52:37 -0500 Subject: [PATCH 076/153] fixed wired trigger: User step on furni when on roller --- .../habbo/habbohotel/items/interactions/InteractionRoller.java | 1 + src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- .../outgoing/rooms/users/RoomUnitOnRollerComposer.java | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java index 09a9a846..10489695 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java @@ -16,6 +16,7 @@ import java.util.List; public class InteractionRoller extends HabboItem { public static boolean NO_RULES = false; + public static int DELAY = 400; public InteractionRoller(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); 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 91d0671c..3c537005 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1459,7 +1459,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } - }, 500); + }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index 0b14605e..f77d520c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -1,6 +1,7 @@ package com.eu.habbo.messages.outgoing.rooms.users; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionRoller; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -65,7 +66,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer { RoomUnitOnRollerComposer.this.roomUnit.setZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight()); RoomUnitOnRollerComposer.this.roomUnit.sitUpdate = true; } - }, this.room.getRollerSpeed() == 0 ? 250 : 400); + }, this.room.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); } else { this.roomUnit.setLocation(this.newLocation); this.roomUnit.setZ(this.newZ); From 899d6cd95ab325ce3df007bfde7e110dbcfb8148 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 31 Jan 2020 19:00:44 +0200 Subject: [PATCH 077/153] Add better error logging to catalog manager --- .../java/com/eu/habbo/habbohotel/catalog/CatalogManager.java | 3 +++ 1 file changed, 3 insertions(+) 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 68db8eea..009b0828 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -40,6 +40,7 @@ import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import java.lang.reflect.InvocationTargetException; import java.sql.*; import java.util.*; import java.util.stream.Collectors; @@ -729,6 +730,8 @@ public class CatalogManager { if (pageClazz != null) { try { catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page); + } catch (InvocationTargetException e) { + Emulator.getLogging().logErrorLine(e.getCause()); } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } From ff2256f30afc30eaf242c46b1dd6d9de72bc41d3 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 12:54:59 +0200 Subject: [PATCH 078/153] Fix furni not jumping on top if not on top already --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 3c537005..f47754a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4488,7 +4488,7 @@ public class Room implements Comparable, ISerialize, Runnable { //Place at new position double height = this.getStackHeight(tile.x, tile.y, false, item); - if (tile.x == item.getX() && tile.y == item.getY()) height = item.getZ(); + if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) height = item.getZ(); if(height > 40d) return FurnitureMovementError.CANT_STACK; item.setX(tile.x); From 24f84a5b02dc59ef9bd2e1860dbea8c48b5513a7 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 13:13:21 +0200 Subject: [PATCH 079/153] Fix snapshot wired updating position even if not enabled --- .../wired/effects/WiredEffectMatchFurni.java | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index 796eca31..dc90e2b7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -16,7 +16,6 @@ import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer; import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; @@ -75,50 +74,50 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { }); } - RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y); + RoomTile t = null; if (this.position) { - if (t != null) { - if (t.state != RoomTileState.INVALID) { - boolean canMove = true; + t = room.getLayout().getTile((short) setting.x, (short) setting.y); - if (t.x == item.getX() && t.y == item.getY()) { - canMove = !(room.getTopItemAt(t.x, t.y) == item); - slideAnimation = false; - } + if (t != null && t.state != RoomTileState.INVALID) { + boolean canMove = true; - if (canMove && !room.hasHabbosAt(t.x, t.y)) { - THashSet tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation); - double highestZ = -1d; - for (RoomTile tile : tiles) { - if (tile.state == RoomTileState.INVALID) { - highestZ = -1d; - break; - } + if (t.x == item.getX() && t.y == item.getY()) { + canMove = !(room.getTopItemAt(t.x, t.y) == item); + slideAnimation = false; + } - if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y)) { - highestZ = -1d; - break; - } - - double stackHeight = room.getStackHeight(tile.x, tile.y, false, item); - if (stackHeight > highestZ) { - highestZ = stackHeight; - } + if (canMove && !room.hasHabbosAt(t.x, t.y)) { + THashSet tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation); + double highestZ = -1d; + for (RoomTile tile : tiles) { + if (tile.state == RoomTileState.INVALID) { + highestZ = -1d; + break; } - if (highestZ != -1d) { - tilesToUpdate.addAll(tiles); + if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y)) { + highestZ = -1d; + break; + } - offsetZ = highestZ - item.getZ(); - double totalHeight = item.getZ() + offsetZ; - if (totalHeight > 40) break; - tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation)); + double stackHeight = room.getStackHeight(tile.x, tile.y, false, item); + if (stackHeight > highestZ) { + highestZ = stackHeight; + } + } - if (!slideAnimation) { - item.setX(t.x); - item.setY(t.y); - } + if (highestZ != -1d) { + tilesToUpdate.addAll(tiles); + + offsetZ = highestZ - item.getZ(); + double totalHeight = item.getZ() + offsetZ; + if (totalHeight > 40) break; + tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation)); + + if (!slideAnimation) { + item.setX(t.x); + item.setY(t.y); } } } @@ -127,6 +126,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { if (slideAnimation && t != null) { room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose()); + room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } else { room.updateItem(item); } From 8e54b357e16394a44dec00189292ea14ae6ee66c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 13:22:35 +0200 Subject: [PATCH 080/153] Fix glitchy animation when moving a chair under a moving avatar --- .../com/eu/habbo/habbohotel/rooms/Room.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index f47754a5..29a7748c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -26,7 +26,8 @@ import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.*; -import com.eu.habbo.habbohotel.wired.*; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -78,6 +79,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; public class Room implements Comparable, ISerialize, Runnable { public static final Comparator SORT_SCORE = new Comparator() { @@ -720,8 +722,10 @@ public class Room implements Comparable, ISerialize, Runnable { } public void updateHabbosAt(short x, short y) { - THashSet habbos = this.getHabbosAt(x, y); + this.updateHabbosAt(x, y, this.getHabbosAt(x, y)); + } + public void updateHabbosAt(short x, short y, THashSet habbos) { HabboItem item = this.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); @@ -4516,7 +4520,14 @@ public class Room implements Comparable, ISerialize, Runnable { //Update Habbos at old position for (RoomTile t : occupiedTiles) { - this.updateHabbosAt(t.x, t.y); + this.updateHabbosAt( + t.x, + t.y, + this.getHabbosAt(t.x, t.y) + .stream() + .filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) + .collect(Collectors.toCollection(THashSet::new)) + ); this.updateBotsAt(t.x, t.y); } return FurnitureMovementError.NONE; From 99168d57a5e2331dd5a2d7a6c3fb4f141e80aaec Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 14:09:59 +0200 Subject: [PATCH 081/153] Fix jukebox disc adding/removing --- .../interactions/InteractionMusicDisc.java | 13 +-- .../habbo/habbohotel/rooms/TraxManager.java | 103 ++++++++++++------ .../jukebox/JukeBoxAddSoundTrackEvent.java | 17 ++- .../rooms/items/jukebox/JukeBoxEventOne.java | 2 +- .../rooms/items/jukebox/JukeBoxEventTwo.java | 2 +- .../jukebox/JukeBoxRequestPlayListEvent.java | 2 +- 6 files changed, 84 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java index a0e245b7..9a163257 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java @@ -13,7 +13,6 @@ import java.sql.SQLException; public class InteractionMusicDisc extends HabboItem { private int songId; - private boolean inQueue; public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -74,21 +73,13 @@ public class InteractionMusicDisc extends HabboItem { public void onPlace(Room room) { super.onPlace(room); - room.sendComposer(new JukeBoxMySongsComposer(room.getTraxManager().myList()).compose()); + room.getTraxManager().sendUpdatedSongList(); } @Override public void onPickUp(Room room) { super.onPickUp(room); - room.getTraxManager().removeSong(this.getId()); - } - - public boolean inQueue() { - return this.inQueue; - } - - public void inQueue(boolean inQueue) { - this.inQueue = inQueue; + room.getTraxManager().sendUpdatedSongList(); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 075ce283..04b13d82 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -3,11 +3,15 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.core.Disposable; import com.eu.habbo.habbohotel.achievements.AchievementManager; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; +import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; +import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxNowPlayingMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer; @@ -18,6 +22,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; public class TraxManager implements Disposable { private final Room room; @@ -38,8 +43,18 @@ public class TraxManager implements Disposable { statement.setInt(1, this.room.getId()); try (ResultSet set = statement.executeQuery()) { while (set.next()) { - HabboItem musicDisc = this.room.getHabboItem(set.getInt("item_id")); - if (musicDisc instanceof InteractionMusicDisc) { + HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); + + if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) { + try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) { + stmt.setInt(1, this.room.getId()); + stmt.setInt(2, musicDisc.getId()); + stmt.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + return; + } + } else { SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId()); if (track != null) { @@ -128,29 +143,32 @@ public class TraxManager implements Disposable { return null; } - public void addSong(int itemId) { - HabboItem musicDisc = this.room.getHabboItem(itemId); + public void addSong(InteractionMusicDisc musicDisc, Habbo habbo) { + SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(musicDisc.getSongId()); - if (musicDisc instanceof InteractionMusicDisc) { - SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId()); + if (track != null) { + this.totalLength += track.getLength(); + this.songs.add(musicDisc); - if (track != null) { - this.totalLength += track.getLength(); - this.songs.add((InteractionMusicDisc) musicDisc); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) { - statement.setInt(1, this.room.getId()); - statement.setInt(2, itemId); - statement.execute(); - } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - return; - } - - this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose()); - this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose()); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_trax_playlist (room_id, item_id) VALUES (?, ?)")) { + statement.setInt(1, this.room.getId()); + statement.setInt(2, musicDisc.getId()); + statement.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + return; } + + this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose()); + + musicDisc.setRoomId(-1); + musicDisc.needsUpdate(true); + + habbo.getInventory().getItemsComponent().removeHabboItem(musicDisc); + habbo.getClient().sendResponse(new RemoveHabboItemComposer(musicDisc.getGiftAdjustedId())); } + + this.sendUpdatedSongList(); } public void removeSong(int itemId) { @@ -174,8 +192,34 @@ public class TraxManager implements Disposable { } this.room.sendComposer(new JukeBoxPlayListComposer(this.songs, this.totalLength).compose()); + + musicDisc.setRoomId(0); + musicDisc.needsUpdate(true); + + Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getUserId()); + + if (owner != null) { + owner.getInventory().getItemsComponent().addItem(musicDisc); + + GameClient client = owner.getClient(); + if (client != null) { + client.sendResponse(new AddHabboItemComposer(musicDisc)); + client.sendResponse(new InventoryRefreshComposer()); + } + } } - this.room.sendComposer(new JukeBoxMySongsComposer(this.myList()).compose()); + + this.sendUpdatedSongList(); + } + + public void sendUpdatedSongList() { + this.room.getHabbos().forEach(h -> { + GameClient client = h.getClient(); + + if (client != null) { + client.sendResponse(new JukeBoxMySongsComposer(this.myList(h))); + } + }); } public int timePlaying() { @@ -208,16 +252,11 @@ public class TraxManager implements Disposable { return trax; } - public List myList() { - List trax = new ArrayList<>(); - - for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionMusicDisc.class)) { - if (!this.songs.contains(item)) { - trax.add((InteractionMusicDisc) item); - } - } - - return trax; + public List myList(Habbo habbo) { + return habbo.getInventory().getItemsComponent().getItems().valueCollection().stream() + .filter(i -> i instanceof InteractionMusicDisc && i.getRoomId() == 0) + .map(i -> (InteractionMusicDisc) i) + .collect(Collectors.toList()); } public InteractionMusicDisc fromItemId(int itemId) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java index 273e62e4..8585c567 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxAddSoundTrackEvent.java @@ -2,26 +2,25 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; public class JukeBoxAddSoundTrackEvent extends MessageHandler { @Override public void handle() throws Exception { + if (!this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) return; + int itemId = this.packet.readInt(); int unknown = this.packet.readInt(); - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Habbo habbo = this.client.getHabbo(); - if (room != null) { - HabboItem item = room.getHabboItem(itemId); + if (habbo != null) { + HabboItem item = habbo.getInventory().getItemsComponent().getHabboItem(itemId); - if (item instanceof InteractionMusicDisc) { - - - if (this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().addSong(itemId); - } + if (item != null && item instanceof InteractionMusicDisc && item.getRoomId() == 0) { + this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().addSong((InteractionMusicDisc) item, habbo); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java index 3e4dd7d6..ad2929f7 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java @@ -10,7 +10,7 @@ public class JukeBoxEventOne extends MessageHandler { public void handle() throws Exception { TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); - this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList())); + this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo()))); this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java index 41a86a7d..15c53b0e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventTwo.java @@ -10,7 +10,7 @@ public class JukeBoxEventTwo extends MessageHandler { public void handle() throws Exception { TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); - this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList())); + this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo()))); this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java index 88bcd1c4..a5468d59 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java @@ -10,7 +10,7 @@ public class JukeBoxRequestPlayListEvent extends MessageHandler { public void handle() throws Exception { TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); - this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList())); + this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo()))); this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); } } From 9561c0b073ec69ad4f50ca088961b955d35c60c1 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 14:15:49 +0200 Subject: [PATCH 082/153] Fix NPE in SecureLoginEvent --- .../users/inventory/EffectsComponent.java | 3 +-- .../incoming/handshake/SecureLoginEvent.java | 2 +- .../outgoing/inventory/UserEffectsListComposer.java | 13 +++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) 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 b1e50d72..591ab435 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 @@ -14,12 +14,11 @@ import java.sql.ResultSet; import java.sql.SQLException; public class EffectsComponent { - public final THashMap effects; + public final THashMap effects = new THashMap<>(); public final Habbo habbo; public int activatedEffect = 0; public EffectsComponent(Habbo habbo) { - this.effects = new THashMap<>(); this.habbo = habbo; try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_effects WHERE user_id = ?")) { statement.setInt(1, habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 86d75859..0a8f2685 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -102,7 +102,7 @@ public class SecureLoginEvent extends MessageHandler { messages.add(new SecureLoginOKComposer().compose()); messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), 0).compose()); - messages.add(new UserEffectsListComposer(habbo, client.getHabbo().getInventory().getEffectsComponent().effects.values().toArray(new EffectsComponent.HabboEffect[0])).compose()); + messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose()); messages.add(new UserClothesComposer(this.client.getHabbo()).compose()); messages.add(new NewUserIdentityComposer(habbo).compose()); messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose()); 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 b1cd6cd6..2c09b324 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 @@ -6,13 +6,15 @@ import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; -import gnu.trove.procedure.TObjectProcedure; + +import java.util.Collection; + public class UserEffectsListComposer extends MessageComposer { public final Habbo habbo; - public final EffectsComponent.HabboEffect[] effects; + public final Collection effects; - public UserEffectsListComposer(Habbo habbo, EffectsComponent.HabboEffect[] effects) { + public UserEffectsListComposer(Habbo habbo, Collection effects) { this.habbo = habbo; this.effects = effects; } @@ -26,10 +28,9 @@ public class UserEffectsListComposer extends MessageComposer { this.response.appendInt(0); } else { synchronized (this.habbo.getInventory().getEffectsComponent().effects) { - this.response.appendInt(this.effects.length); - - for(EffectsComponent.HabboEffect effect : effects) { + this.response.appendInt(this.effects.size()); + for (EffectsComponent.HabboEffect effect : effects) { UserEffectsListComposer.this.response.appendInt(effect.effect); UserEffectsListComposer.this.response.appendInt(0); UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : Integer.MAX_VALUE); From add7156b9ae4ad4abf6fc615a974a86973da00eb Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 20:29:40 +0200 Subject: [PATCH 083/153] Modify default repeater wired delays (credit: kittihab / Kitt Mustang) --- .../items/interactions/wired/triggers/WiredTriggerRepeater.java | 2 +- .../interactions/wired/triggers/WiredTriggerRepeaterLong.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index d7fd07b4..a0f693c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -21,7 +21,7 @@ import java.util.List; public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { public static final WiredTriggerType type = WiredTriggerType.PERIODICALLY; - public static final int DEFAULT_DELAY = 20 * 500; + public static final int DEFAULT_DELAY = 10 * 500; protected int repeatTime = DEFAULT_DELAY; protected int counter = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 7020988e..ff3f9688 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements ICycleable, WiredTriggerReset { - public static final int DEFAULT_DELAY = 20 * 5000; + public static final int DEFAULT_DELAY = 10 * 5000; private static final WiredTriggerType type = WiredTriggerType.PERIODICALLY_LONG; private int repeatTime = DEFAULT_DELAY; private int counter = 0; From 44de2a81ec975ba412667b88691fefec5856d2e6 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 1 Feb 2020 20:32:29 +0200 Subject: [PATCH 084/153] Fix NPE in WiredHandler --- .../java/com/eu/habbo/habbohotel/wired/WiredHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 aa600682..a88ff69f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -415,11 +415,13 @@ public class WiredHandler { } public static void resetTimers(Room room) { - if (!room.isLoaded()) + if (!room.isLoaded() || room.getRoomSpecialTypes() == null) return; - room.getRoomSpecialTypes().getTriggers().forEach(t-> { - if(t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG) { + room.getRoomSpecialTypes().getTriggers().forEach(t -> { + if (t == null) return; + + if (t.getType() == WiredTriggerType.AT_GIVEN_TIME || t.getType() == WiredTriggerType.PERIODICALLY || t.getType() == WiredTriggerType.PERIODICALLY_LONG) { ((WiredTriggerReset) t).resetTimer(); } }); From ed49bd3336b30627ed85c2579eac35451b253e69 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sat, 1 Feb 2020 15:37:23 -0500 Subject: [PATCH 085/153] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0792d824..e56d1cca 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 - Alejandro - Harmony - Quadral (Pathfinder) +- Skeletor +- z ## Discord ## Join us on Discord at https://discord.gg/BzfFsTp From fa3755341efcfde4b18f7e6313fb304bf2aa8ede Mon Sep 17 00:00:00 2001 From: skeletor Date: Sun, 2 Feb 2020 04:06:44 -0500 Subject: [PATCH 086/153] set client to game mode when in a game --- src/main/java/com/eu/habbo/habbohotel/games/Game.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index 359792d8..943734eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.messages.outgoing.guides.GuideSessionPartnerIsPlayingComposer; import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.games.GameHabboJoinEvent; import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent; @@ -68,7 +69,7 @@ public abstract class Game implements Runnable { habbo.getHabboInfo().setCurrentGame(this.getClass()); habbo.getHabboInfo().setGamePlayer(player); } - + habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(true)); return true; } } catch (Exception e) { @@ -94,7 +95,7 @@ public abstract class Game implements Runnable { habbo.getHabboInfo().getGamePlayer().reset(); habbo.getHabboInfo().setCurrentGame(null); habbo.getHabboInfo().setGamePlayer(null); - + habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(false)); if (this.countsAchievements && this.endTime > this.startTime) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GamePlayed")); } From 304907ddf13ee6fc3a865384a98c944951b8c3d3 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 14:09:48 +0200 Subject: [PATCH 087/153] Reset banzai tile state on pickup --- .../InteractionBattleBanzaiTile.java | 19 +++++++++++++++++++ .../items/MoodLightSaveSettingsEvent.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java index 24e98ed6..8e364615 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java @@ -99,4 +99,23 @@ public class InteractionBattleBanzaiTile extends HabboItem { return super.canStackAt(room, itemsAtLocation); } + + @Override + public void onPickUp(Room room) { + super.onPickUp(room); + + this.setExtradata("0"); + room.updateItem(this); + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + + BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class); + + if (game != null && game.getState() != GameState.IDLE) { + this.setExtradata("1"); + } + } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index 3c2e8d4e..105152da 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -13,7 +13,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if ((room.getGuildId() > 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo())) + if ((room.getGuildId() <= 0 && room.guildRightLevel(this.client.getHabbo()) < 2) && !room.hasRights(this.client.getHabbo())) return; int id = this.packet.readInt(); From ae412592b10e40eb41eb17e300f2c95a3ed588eb Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 14:12:34 +0200 Subject: [PATCH 088/153] Make single-player banzai games not give achievements --- .../games/battlebanzai/BattleBanzaiGame.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index 3b390138..074d494a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -157,11 +157,14 @@ public class BattleBanzaiGame extends Game { public void onEnd() { GameTeam winningTeam = null; + boolean singleTeamGame = this.teams.values().stream().filter(t -> t.getMembers().size() > 0).count() == 1; + for (GameTeam team : this.teams.values()) { - for (GamePlayer player : team.getMembers()) { - if (player.getScore() > 0) { - AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer")); - AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallQuestCompleted")); + if (!singleTeamGame) { + for (GamePlayer player : team.getMembers()) { + if (player.getScore() > 0) { + AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallPlayer")); + } } } @@ -171,10 +174,12 @@ public class BattleBanzaiGame extends Game { } if (winningTeam != null) { - for (GamePlayer player : winningTeam.getMembers()) { - if (player.getScore() > 0) { - this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose()); - AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner")); + if (!singleTeamGame) { + for (GamePlayer player : winningTeam.getMembers()) { + if (player.getScore() > 0) { + this.room.sendComposer(new RoomUserActionComposer(player.getHabbo().getRoomUnit(), RoomUserAction.WAVE).compose()); + AchievementManager.progressAchievement(player.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallWinner")); + } } } From 8bfaeed69d09f05832301ee3356502bc55a9fb08 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 14:17:16 +0200 Subject: [PATCH 089/153] Fix marketplace query ambiguity --- .../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 1a7109dc..2e978403 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 @@ -171,7 +171,7 @@ public class MarketPlace { public static void serializeItemInfo(int itemId, ServerMessage message) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(timestamp))")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))")) { statement.setInt(1, itemId); message.appendInt(avarageLastXDays(itemId, 7)); From 1e3067f2cef3a0c46a4082d862d03221d01e4a58 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 14:23:57 +0200 Subject: [PATCH 090/153] Fix banzai puck not being able to move in empty rooms --- .../games/battlebanzai/InteractionBattleBanzaiPuck.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java index 1ff4c3c7..5c28cda7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java @@ -124,10 +124,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable { @Override public boolean validMove(Room room, RoomTile from, RoomTile to) { - if (room == null || from == null || to == null) return false; - - HabboItem topItem = room.getTopItemAt(to.x, to.y, this); - return topItem != null; + return room != null && from != null && to != null; //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); } From 9ee11df10fbadd881157affa5f88d0e5002285a5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 18:20:31 +0200 Subject: [PATCH 091/153] Fix switching between moodlight presets --- .../items/MoodLightSaveSettingsEvent.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index 105152da..e953255c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -2,13 +2,19 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionMoodLight; +import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomMoodlightData; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.MoodLightDataComposer; +import java.util.Arrays; +import java.util.List; + public class MoodLightSaveSettingsEvent extends MessageHandler { + public static List MOODLIGHT_AVAILABLE_COLORS = Arrays.asList("#74F5F5,#0053F7,#E759DE,#EA4532,#F2F851,#82F349,#000000".split(",")); + @Override public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); @@ -19,14 +25,25 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { int id = this.packet.readInt(); int backgroundOnly = this.packet.readInt(); String color = this.packet.readString(); - int intensity = this.packet.readInt(); + int brightness = this.packet.readInt(); + boolean apply = this.packet.readBoolean(); + + if (!MOODLIGHT_AVAILABLE_COLORS.contains(color)) { + ScripterManager.scripterDetected(this.client, "User tried to set a moodlight to a non-whitelisted color: " + color); + return; + } + + if (brightness > 0xFF || brightness <= (0.3 * 0xFF)) { + ScripterManager.scripterDetected(this.client, "User tried to set a moodlight's brightness to out-of-bounds ([76, 255]): " + brightness); + return; + } for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) { if (data.getId() == id) { data.setBackgroundOnly(backgroundOnly == 2); data.setColor(color); - data.setIntensity(intensity); - data.enable(); + data.setIntensity(brightness); + if (apply) data.enable(); for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { item.setExtradata(data.toString()); @@ -34,7 +51,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { room.updateItem(item); Emulator.getThreading().run(item); } - } else { + } else if (apply) { data.disable(); } } From 2cb33a5ec6519e2d30867f971d7f3e42699227e3 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 20:52:17 +0200 Subject: [PATCH 092/153] Make game timers end the game at 00:00 --- .../items/interactions/games/InteractionGameTimer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 94e01be1..6c0ff65e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -153,16 +153,20 @@ public class InteractionGameTimer extends HabboItem implements Runnable { return; } + this.timeNow--; + if (this.timeNow < 0) this.timeNow = 0; + if (this.timeNow > 0) { this.threadActive = true; Emulator.getThreading().run(this, 1000); - this.timeNow--; - room.updateItem(this); } else { this.threadActive = false; + this.timeNow = 0; this.endGame(room); WiredHandler.handle(WiredTriggerType.GAME_ENDS, null, room, new Object[]{}); } + + room.updateItem(this); } @Override From fbdf56f22f844f24f997d479acaa7fd23fe76fae Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 22:17:08 +0200 Subject: [PATCH 093/153] Fix glitchy freeze scoreboards (negative scores) --- src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java index edc62fb4..1950c917 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java @@ -29,6 +29,9 @@ public class GamePlayer { public synchronized void addScore(int amount) { if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) { this.score += amount; + + if (this.score < 0) this.score = 0; + WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount}); } } From a668cb9802bcb012dcab4b58453c9c523a3e3d2f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 4 Feb 2020 23:04:41 +0200 Subject: [PATCH 094/153] Add saddle removing --- sqlupdates/2_3_0-RC-2_TO_2_3_0.sql | 2 + .../eu/habbo/habbohotel/pets/HorsePet.java | 6 +- .../eu/habbo/habbohotel/pets/RideablePet.java | 9 +++ .../com/eu/habbo/messages/PacketManager.java | 3 +- .../eu/habbo/messages/PacketManager_1006.java | 2 +- .../eu/habbo/messages/incoming/Incoming.java | 3 +- .../rooms/pets/HorseRemoveSaddleEvent.java | 64 +++++++++++++++++++ .../incoming/rooms/pets/PetUseItemEvent.java | 1 + 8 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 sqlupdates/2_3_0-RC-2_TO_2_3_0.sql create mode 100644 src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java diff --git a/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql new file mode 100644 index 00000000..7d46d35d --- /dev/null +++ b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql @@ -0,0 +1,2 @@ +ALTER TABLE `users_pets` +ADD COLUMN `saddle_item_id` int(11) NULL; \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java index 87be3a16..46704168 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -17,6 +17,7 @@ public class HorsePet extends RideablePet { this.hairStyle = set.getInt("hair_style"); this.hasSaddle(set.getString("saddle").equalsIgnoreCase("1")); this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1")); + this.setSaddleItemId(set.getInt("saddle_item_id")); } public HorsePet(int type, int race, String color, String name, int userId) { @@ -30,12 +31,13 @@ public class HorsePet extends RideablePet { @Override public void run() { if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ? WHERE id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ?, saddle_item_id = ? WHERE id = ?")) { statement.setInt(1, this.hairStyle); statement.setInt(2, this.hairColor); statement.setString(3, this.hasSaddle() ? "1" : "0"); statement.setString(4, this.anyoneCanRide() ? "1" : "0"); - statement.setInt(5, super.getId()); + statement.setInt(5, this.getSaddleItemId()); + statement.setInt(6, super.getId()); statement.execute(); } catch (SQLException e) { Emulator.getLogging().logSQLException(e); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java index 92ec07a7..afdb4b39 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/RideablePet.java @@ -10,6 +10,7 @@ public class RideablePet extends Pet { private Habbo rider; private boolean hasSaddle; private boolean anyoneCanRide; + private int saddleItemId; public RideablePet(ResultSet set) throws SQLException { super(set); @@ -44,4 +45,12 @@ public class RideablePet extends Pet { public void setRider(Habbo rider) { this.rider = rider; } + + public int getSaddleItemId() { + return saddleItemId; + } + + public void setSaddleItemId(int saddleItemId) { + this.saddleItemId = saddleItemId; + } } diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 1a6c73a1..7ebfe092 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -542,9 +542,10 @@ public class PacketManager { this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class); this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class); this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class); - this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class); + this.registerHandler(Incoming.PetUseItemEvent, PetUseItemEvent.class); this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class); this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class); + this.registerHandler(Incoming.HorseRemoveSaddleEvent, HorseRemoveSaddleEvent.class); this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class); this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class); this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class); diff --git a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java index 6d11324f..93edd722 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager_1006.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager_1006.java @@ -372,7 +372,7 @@ public class PacketManager_1006 { this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class); this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class); this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class); - this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class); + this.registerHandler(Incoming.PetUseItemEvent, PetUseItemEvent.class); this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class); this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index a38210d6..dea1137b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -64,7 +64,8 @@ public class Incoming { public static final int SearchRoomsFriendsNowEvent = 1786; public static final int SetStackHelperHeightEvent = 3839; public static final int RedeemVoucherEvent = 339; - public static final int HorseUseItemEvent = 1328; + public static final int PetUseItemEvent = 1328; + public static final int HorseRemoveSaddleEvent = 186; public static final int BuyItemEvent = 1603; public static final int AdvertisingSaveEvent = 3608; public static final int RequestPetTrainingPanelEvent = 2161; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java new file mode 100644 index 00000000..2c837e98 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java @@ -0,0 +1,64 @@ +package com.eu.habbo.messages.incoming.rooms.pets; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.pets.HorsePet; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; +import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetHorseFigureComposer; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class HorseRemoveSaddleEvent extends MessageHandler { + @Override + public void handle() throws Exception { + Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); + Pet pet = room.getPet(this.packet.readInt()); + + if (pet == null || !(pet instanceof HorsePet)) return; + + HorsePet horse = (HorsePet) pet; + + if (!horse.hasSaddle()) return; + + int saddleItemId = horse.getSaddleItemId(); + + if (saddleItemId == 0) { // backwards compatibility: horses could be missing the saddle item ID + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM items_base WHERE item_name LIKE 'horse_saddle%' LIMIT 1")) { + try (ResultSet set = statement.executeQuery()) { + if (set.next()) { + saddleItemId = set.getInt("id"); + } else { + Emulator.getLogging().logErrorLine("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId()); + return; + } + } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + + Item saddleItem = Emulator.getGameEnvironment().getItemManager().getItem(saddleItemId); + + if (saddleItem == null) return; + + horse.hasSaddle(false); + horse.needsUpdate = true; + Emulator.getThreading().run(pet); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomPetHorseFigureComposer(horse).compose()); + + HabboItem saddle = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), saddleItem, 0, 0, ""); + + this.client.getHabbo().getInventory().getItemsComponent().addItem(saddle); + + this.client.sendResponse(new AddHabboItemComposer(saddle)); + this.client.sendResponse(new InventoryRefreshComposer()); + } +} diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java index 2b597245..7ec34b79 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetUseItemEvent.java @@ -75,6 +75,7 @@ public class PetUseItemEvent extends MessageHandler { ((HorsePet) pet).needsUpdate = true; } else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) { ((HorsePet) pet).hasSaddle(true); + ((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId()); ((HorsePet) pet).needsUpdate = true; } From e399304c1c70a4f877f43d5a3945e30cb2fefc6a Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 5 Feb 2020 07:17:47 -0500 Subject: [PATCH 095/153] fix concurrentException in wired highscores --- .../habbohotel/wired/highscores/WiredHighscoreManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index 1873b2de..5e797bec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -92,7 +92,7 @@ public class WiredHighscoreManager { public List getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) { if (!this.data.containsKey(itemId)) return null; - Stream highscores = this.data.get(itemId).stream() + Stream highscores = new ArrayList<>(this.data.get(itemId)).stream() .filter(entry -> this.timeMatchesEntry(entry, clearType) && (scoreType != WiredHighscoreScoreType.MOSTWIN || entry.isWin())) .map(entry -> new WiredHighscoreRow( entry.getUserIds().stream() From 5f5345c80c6ec233793d04749e0314515444c57d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 14:26:02 +0200 Subject: [PATCH 096/153] Ensure the user removing a saddle is the horse's owner --- .../messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java index 2c837e98..5f89d1fd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java @@ -22,7 +22,7 @@ public class HorseRemoveSaddleEvent extends MessageHandler { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); Pet pet = room.getPet(this.packet.readInt()); - if (pet == null || !(pet instanceof HorsePet)) return; + if (pet == null || !(pet instanceof HorsePet) || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return; HorsePet horse = (HorsePet) pet; From f240580c1e3b517dbc504b5a39359f0298380496 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 19:17:51 +0200 Subject: [PATCH 097/153] Add bot placement message --- sqlupdates/2_3_0-RC-2_TO_2_3_0.sql | 4 +++- src/main/java/com/eu/habbo/habbohotel/bots/Bot.java | 4 ++++ src/main/java/com/eu/habbo/plugin/PluginManager.java | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql index 7d46d35d..866278ca 100644 --- a/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql +++ b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql @@ -1,2 +1,4 @@ ALTER TABLE `users_pets` -ADD COLUMN `saddle_item_id` int(11) NULL; \ No newline at end of file +ADD COLUMN `saddle_item_id` int(11) NULL; + +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!'); \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index e6a5d900..d10ed613 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -22,6 +22,8 @@ import java.util.Arrays; public class Bot implements Runnable { public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; + public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); + private final ArrayList chatLines; private transient int id; private String name; @@ -240,6 +242,8 @@ public class Bot implements Runnable { if (this.roomUnit != null) { room.giveEffect(this.roomUnit, this.effect, -1); } + + this.talk(PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]); } public void onPickUp(Habbo habbo, Room room) { diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 2a6c45f9..7edf9579 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -3,6 +3,7 @@ package com.eu.habbo.plugin; import com.eu.habbo.Emulator; import com.eu.habbo.core.Easter; import com.eu.habbo.habbohotel.achievements.AchievementManager; +import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.catalog.TargetOffer; @@ -82,6 +83,8 @@ public class PluginManager { BotManager.MAXIMUM_CHAT_LENGTH = Emulator.getConfig().getInt("hotel.bot.max.chatlength"); BotManager.MAXIMUM_NAME_LENGTH = Emulator.getConfig().getInt("hotel.bot.max.namelength"); BotManager.MAXIMUM_CHAT_SPEED = Emulator.getConfig().getInt("hotel.bot.max.chatdelay"); + Bot.PLACEMENT_MESSAGES = Emulator.getConfig().getValue("hotel.bot.placement.messages", "Yo!;Hello I'm a real party animal!;Hello!").split(";"); + HabboInventory.MAXIMUM_ITEMS = Emulator.getConfig().getInt("hotel.inventory.max.items"); Messenger.MAXIMUM_FRIENDS = Emulator.getConfig().getInt("hotel.max.friends"); Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.max.friends.hc"); From 82ff5c0a08cc8f91c6472be8fa6932dc169c3bf4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 19:35:25 +0200 Subject: [PATCH 098/153] Make bots walk to nearest adjacent tile when giving a handitem --- .../interactions/InteractionPuzzleBox.java | 13 ++------ .../eu/habbo/habbohotel/rooms/RoomUnit.java | 33 ++++++++++++++++--- .../runnables/RoomUnitWalkToRoomUnit.java | 14 +------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java index ca1e4d6e..daff0b5d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java @@ -42,18 +42,9 @@ public class InteractionPuzzleBox extends HabboItem { } if (rotation == null) { - Optional nearestTile = Arrays.stream( - new RoomTile[]{ - room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH.getValue()), - room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH.getValue()), - room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.EAST.getValue()), - room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.WEST.getValue()) - } - ) - .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) - .min(Comparator.comparingDouble(a -> a.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))); + RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), false); - nearestTile.ifPresent(roomTile -> client.getHabbo().getRoomUnit().setGoalLocation(roomTile)); + if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index d4c71610..348fddad 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.*; +import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; +import com.eu.habbo.habbohotel.items.interactions.InteractionHabboClubGate; +import com.eu.habbo.habbohotel.items.interactions.InteractionWater; +import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.users.DanceType; @@ -22,9 +25,7 @@ import gnu.trove.map.TMap; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import java.util.Deque; -import java.util.LinkedList; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class RoomUnit { @@ -743,4 +744,28 @@ public class RoomUnit { return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); } + + public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) { + RoomTile baseTile = room.getLayout().getTile(x, y); + + if (baseTile == null) return null; + + List rotations = new ArrayList<>(); + rotations.add(RoomUserRotation.SOUTH.getValue()); + rotations.add(RoomUserRotation.NORTH.getValue()); + rotations.add(RoomUserRotation.EAST.getValue()); + rotations.add(RoomUserRotation.WEST.getValue()); + + if (diagonal) { + rotations.add(RoomUserRotation.NORTH_EAST.getValue()); + rotations.add(RoomUserRotation.NORTH_WEST.getValue()); + rotations.add(RoomUserRotation.SOUTH_EAST.getValue()); + rotations.add(RoomUserRotation.SOUTH_WEST.getValue()); + } + + return rotations.stream() + .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) + .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) + .min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null); + } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java index 1eeac72d..e8ef0c71 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -74,23 +74,11 @@ public class RoomUnitWalkToRoomUnit implements Runnable { } private void findNewLocation() { - this.goalTile = this.room.getLayout().getTileInFront(this.target.getCurrentLocation(), this.target.getBodyRotation().getValue()); + this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().x, this.target.getCurrentLocation().y, true); if (this.goalTile == null) return; - if (!this.room.tileWalkable(this.goalTile)) { - List tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation()); - - for (RoomTile t : tiles) { - if (this.room.tileWalkable(t)) { - this.goalTile = t; - - break; - } - } - } - this.walker.setGoalLocation(this.goalTile); if (this.walker.getPath().isEmpty() && this.failedReached != null) { From 913f84ac46d51ace128e75adde883b17705f1d50 Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 5 Feb 2020 12:39:16 -0500 Subject: [PATCH 099/153] Small refactoring of Wired Effect: Move Rotate -Fixed rotating and moving furniture at the same time -Fixed random movement direction finding correct tile too fast -Fixed movement of furniture larger than 2 tiles --- .../effects/WiredEffectMoveRotateFurni.java | 295 +++++++++--------- 1 file changed, 147 insertions(+), 148 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index c83fcad7..0c3f38f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -39,174 +39,117 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = new THashSet<>(this.items.size()); + // remove items that are no longer in the room + this.items.removeIf( item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); + THashSet tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10)); - for (HabboItem item : this.items) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - for (HabboItem item : this.items) { //Handle rotation - int rotationToAdd = 0; if (this.rotation > 0) { tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - if (this.rotation == 1) { - rotationToAdd = 2; - } else if (this.rotation == 2) { - rotationToAdd = 6; - } - //Random rotation - else if (this.rotation == 3) { - if (Emulator.getRandom().nextInt(2) == 1) { - rotationToAdd = 2; - } else { - rotationToAdd = 6; - } - } - } + int newRotation = this.getNewRotation(item); - int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); - //Verify if rotation result in a valid position - FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); - if (rotationToAdd > 0 && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || - rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) - { - item.setRotation(newRotation); - - if (this.direction == 0) { - tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - room.sendComposer(new FloorItemUpdateComposer(item).compose()); - for (RoomTile t : tilesToUpdate) { - room.updateHabbosAt(t.x, t.y); - room.updateBotsAt(t.x, t.y); - } - } - } - - if (this.direction > 0) { - int nextDirectionOffset = 0; - RoomUserRotation startMoveDirection = RoomUserRotation.NORTH; - RoomUserRotation moveDirection = null; - if (this.direction == 1) { - startMoveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; - nextDirectionOffset = 2; - } else if (this.direction == 2) { - if (Emulator.getRandom().nextInt(2) == 1) { - startMoveDirection = RoomUserRotation.EAST; - nextDirectionOffset = 4; - } else { - startMoveDirection = RoomUserRotation.WEST; - nextDirectionOffset = 4; - } - } else if (this.direction == 3) { - if (Emulator.getRandom().nextInt(2) == 1) { - startMoveDirection = RoomUserRotation.NORTH; - nextDirectionOffset = 4; - } else { - startMoveDirection = RoomUserRotation.SOUTH; - nextDirectionOffset = 4; - } - } else if (this.direction == 4) { - startMoveDirection = RoomUserRotation.SOUTH; - nextDirectionOffset = 8; - } else if (this.direction == 5) { - startMoveDirection = RoomUserRotation.EAST; - nextDirectionOffset = 8; - } else if (this.direction == 6) { - startMoveDirection = RoomUserRotation.NORTH; - nextDirectionOffset = 8; - } else if (this.direction == 7) { - startMoveDirection = RoomUserRotation.WEST; - nextDirectionOffset = 8; - } - - boolean validMove = false; - - int count = 0; - int maxCount = 8 / nextDirectionOffset; - while (moveDirection != startMoveDirection && !validMove && count < maxCount) { - count++; - if (moveDirection == null) { - moveDirection = startMoveDirection; - } - RoomLayout layout = room.getLayout(); - if (layout == null) return false; - - RoomTile newTile = layout.getTile( - (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), - (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) - ); - - if (newTile != null) { - boolean hasHabbos = false; - for (Habbo habbo : room.getHabbosAt(newTile)) { - hasHabbos = true; - WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); + //Verify if rotation result in a valid position + FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); + if (item.getRotation() != newRotation && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || + rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) + { + item.setRotation(newRotation); + if(this.direction == 0) { + tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + room.sendComposer(new FloorItemUpdateComposer(item).compose()); + for (RoomTile t : tilesToUpdate) { + room.updateHabbosAt(t.x, t.y); + room.updateBotsAt(t.x, t.y); } + } + } + } - if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { - java.awt.Rectangle rectangle = new Rectangle(newTile.x, - newTile.y, - item.getBaseItem().getWidth(), - item.getBaseItem().getLength()); + //handle movement + if (this.direction > 0) { + RoomUserRotation moveDirection = this.getMovementDirection(); + boolean validMove = false; + RoomLayout layout = room.getLayout(); + if (layout == null) return false; - double offset = -Short.MAX_VALUE; - validMove = true; - for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { - if (!validMove) { + RoomTile newTile = layout.getTile( + (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), + (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) + ); + + if (newTile != null) { + boolean hasHabbos = false; + for (Habbo habbo : room.getHabbosAt(newTile)) { + hasHabbos = true; + WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); + } + + if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { + java.awt.Rectangle rectangle = new Rectangle(newTile.x, + newTile.y, + item.getBaseItem().getWidth(), + item.getBaseItem().getLength()); + + double offset = -Short.MAX_VALUE; + validMove = true; + for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { + if (!validMove) { + break; + } + + for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { + RoomTile tile = layout.getTile(x, y); + if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) { + validMove = false; break; } - for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { - RoomTile tile = layout.getTile(x, y); + THashSet itemsAtNewTile = room.getItemsAt(tile); + if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { + validMove = false; + break; + } - if (tile == null || tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED || !tile.getAllowStack()) { - validMove = false; - break; - } + ArrayList>> tileItems = new ArrayList<>(rectangle.width * rectangle.height); + tileItems.add(Pair.create(tile, itemsAtNewTile)); + if (!item.canStackAt(room, tileItems)) { + validMove = false; + break; + } - THashSet itemsAtNewTile = room.getItemsAt(tile); - if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { - validMove = false; - break; - } + HabboItem i = room.getTopItemAt(x, y, item); + if (i != null && !i.getBaseItem().allowStack()) { + validMove = false; + break; + } - java.util.List tileItems = new ArrayList>>(rectangle.width * rectangle.height); - tileItems.add(Pair.create(tile, itemsAtNewTile)); - if (!item.canStackAt(room, tileItems)) { - validMove = false; - break; - } + offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); - HabboItem i = room.getTopItemAt(x, y, item); - if (i != null && !i.getBaseItem().allowStack()) { - validMove = false; - break; - } + tilesToUpdate.add(tile); + } + } + if (item.getZ() + offset > 40) { + offset = 40 - item.getZ(); + } - offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); - - tilesToUpdate.add(tile); + if (validMove) { + if(this.rotation > 0) { + item.setX(newTile.x); + item.setY(newTile.y); + item.setZ(offset); + room.sendComposer(new FloorItemUpdateComposer(item).compose()); + for (RoomTile t : tilesToUpdate) { + room.updateHabbosAt(t.x, t.y); + room.updateBotsAt(t.x, t.y); } } - if (item.getZ() + offset > 40) { - offset = 40 - item.getZ(); - } - - if (validMove) { + else { room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose()); } } } - if (!validMove) { - moveDirection = RoomUserRotation.fromValue(moveDirection.getValue() + nextDirectionOffset); - } } } } @@ -252,14 +195,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { if (data.length == 4) { try { - this.direction = Integer.valueOf(data[0]); - this.rotation = Integer.valueOf(data[1]); - this.setDelay(Integer.valueOf(data[2])); + this.direction = Integer.parseInt(data[0]); + this.rotation = Integer.parseInt(data[1]); + this.setDelay(Integer.parseInt(data[2])); } catch (Exception e) { } for (String s : data[3].split("\r")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item != null) this.items.add(item); @@ -340,4 +283,60 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { protected long requiredCooldown() { return 100; } + + /** + * Returns a new rotation for an item based on the wired options + * @param item + * @return new rotation + */ + private int getNewRotation(HabboItem item) { + int rotationToAdd = 0; + if (this.rotation == 1) { + rotationToAdd = 2; + } else if (this.rotation == 2) { + rotationToAdd = 6; + } + //Random rotation + else if (this.rotation == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { + rotationToAdd = 2; + } else { + rotationToAdd = 6; + } + } + + return ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); + } + + /** + * Returns the direction of movement based on the wired settings + * @return direction + */ + private RoomUserRotation getMovementDirection() { + RoomUserRotation movemementDirection = RoomUserRotation.NORTH; + if (this.direction == 1) { + movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; + } else if (this.direction == 2) { + if (Emulator.getRandom().nextInt(2) == 1) { + movemementDirection = RoomUserRotation.EAST; + } else { + movemementDirection = RoomUserRotation.WEST; + } + } else if (this.direction == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { + movemementDirection = RoomUserRotation.NORTH; + } else { + movemementDirection = RoomUserRotation.SOUTH; + } + } else if (this.direction == 4) { + movemementDirection = RoomUserRotation.SOUTH; + } else if (this.direction == 5) { + movemementDirection = RoomUserRotation.EAST; + } else if (this.direction == 6) { + movemementDirection = RoomUserRotation.NORTH; + } else if (this.direction == 7) { + movemementDirection = RoomUserRotation.WEST; + } + return movemementDirection; + } } From 4ecba6723d07756c9b8bd0769c1eadf7f352da01 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 19:52:29 +0200 Subject: [PATCH 100/153] Fix giving handitems with bots --- .../effects/WiredEffectBotGiveHandItem.java | 7 +++++- .../runnables/RoomUnitWalkToRoomUnit.java | 24 +++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java index d32e932a..918f12fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java @@ -96,8 +96,13 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { List tasks = new ArrayList<>(); tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId)); tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0)); + Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId)); - Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, null)); + + List failedReach = new ArrayList<>(); + failedReach.add(() -> tasks.forEach(Runnable::run)); + + Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach)); } return true; diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java index e8ef0c71..296490e7 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToRoomUnit.java @@ -47,9 +47,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable { if (this.goalTile == null) return; - if (this.walker.getGoal().equals(this.goalTile)) //Check if the goal is still the same. Chances are something is running the same task. If so we dump this task. - { - //Check if arrived. + if (this.walker.getGoal().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) { for (Runnable r : this.targetReached) { Emulator.getThreading().run(r); @@ -57,17 +55,6 @@ public class RoomUnitWalkToRoomUnit implements Runnable { WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, this.target, this.room, new Object[]{this.walker}); } } else { - List tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation()); - - for (RoomTile t : tiles) { - if (t.equals(this.goalTile)) { - Emulator.getThreading().run(this, 500); - return; - } - } - - this.findNewLocation(); - Emulator.getThreading().run(this, 500); } } @@ -76,8 +63,15 @@ public class RoomUnitWalkToRoomUnit implements Runnable { private void findNewLocation() { this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().x, this.target.getCurrentLocation().y, true); - if (this.goalTile == null) + if (this.goalTile == null) { + if (this.failedReached != null) { + for (Runnable r : this.failedReached) { + Emulator.getThreading().run(r); + } + } + return; + } this.walker.setGoalLocation(this.goalTile); From f0ed16d46dca2ea4170fd6bb91a579bed98aa8dc Mon Sep 17 00:00:00 2001 From: Harmonic Date: Wed, 5 Feb 2020 13:06:30 -0500 Subject: [PATCH 101/153] Revert "Small refactoring of Wired Effect: Move Rotate" This reverts commit 913f84ac46d51ace128e75adde883b17705f1d50 --- .../effects/WiredEffectMoveRotateFurni.java | 293 +++++++++--------- 1 file changed, 147 insertions(+), 146 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 0c3f38f5..c83fcad7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -39,117 +39,174 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - // remove items that are no longer in the room - this.items.removeIf( item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); - + THashSet items = new THashSet<>(this.items.size()); THashSet tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10)); + for (HabboItem item : this.items) { + if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) + items.add(item); + } + + for (HabboItem item : items) { + this.items.remove(item); + } + for (HabboItem item : this.items) { //Handle rotation + int rotationToAdd = 0; if (this.rotation > 0) { tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - int newRotation = this.getNewRotation(item); - - //Verify if rotation result in a valid position - FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); - if (item.getRotation() != newRotation && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || - rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) - { - item.setRotation(newRotation); - if(this.direction == 0) { - tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - room.sendComposer(new FloorItemUpdateComposer(item).compose()); - for (RoomTile t : tilesToUpdate) { - room.updateHabbosAt(t.x, t.y); - room.updateBotsAt(t.x, t.y); - } + if (this.rotation == 1) { + rotationToAdd = 2; + } else if (this.rotation == 2) { + rotationToAdd = 6; + } + //Random rotation + else if (this.rotation == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { + rotationToAdd = 2; + } else { + rotationToAdd = 6; } } } - //handle movement - if (this.direction > 0) { - RoomUserRotation moveDirection = this.getMovementDirection(); - boolean validMove = false; - RoomLayout layout = room.getLayout(); - if (layout == null) return false; + int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); + //Verify if rotation result in a valid position + FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); + if (rotationToAdd > 0 && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || + rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) + { + item.setRotation(newRotation); - RoomTile newTile = layout.getTile( - (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), - (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) - ); - - if (newTile != null) { - boolean hasHabbos = false; - for (Habbo habbo : room.getHabbosAt(newTile)) { - hasHabbos = true; - WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); + if (this.direction == 0) { + tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + room.sendComposer(new FloorItemUpdateComposer(item).compose()); + for (RoomTile t : tilesToUpdate) { + room.updateHabbosAt(t.x, t.y); + room.updateBotsAt(t.x, t.y); } + } + } - if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { - java.awt.Rectangle rectangle = new Rectangle(newTile.x, - newTile.y, - item.getBaseItem().getWidth(), - item.getBaseItem().getLength()); + if (this.direction > 0) { + int nextDirectionOffset = 0; + RoomUserRotation startMoveDirection = RoomUserRotation.NORTH; + RoomUserRotation moveDirection = null; + if (this.direction == 1) { + startMoveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; + nextDirectionOffset = 2; + } else if (this.direction == 2) { + if (Emulator.getRandom().nextInt(2) == 1) { + startMoveDirection = RoomUserRotation.EAST; + nextDirectionOffset = 4; + } else { + startMoveDirection = RoomUserRotation.WEST; + nextDirectionOffset = 4; + } + } else if (this.direction == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { + startMoveDirection = RoomUserRotation.NORTH; + nextDirectionOffset = 4; + } else { + startMoveDirection = RoomUserRotation.SOUTH; + nextDirectionOffset = 4; + } + } else if (this.direction == 4) { + startMoveDirection = RoomUserRotation.SOUTH; + nextDirectionOffset = 8; + } else if (this.direction == 5) { + startMoveDirection = RoomUserRotation.EAST; + nextDirectionOffset = 8; + } else if (this.direction == 6) { + startMoveDirection = RoomUserRotation.NORTH; + nextDirectionOffset = 8; + } else if (this.direction == 7) { + startMoveDirection = RoomUserRotation.WEST; + nextDirectionOffset = 8; + } - double offset = -Short.MAX_VALUE; - validMove = true; - for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { - if (!validMove) { - break; - } + boolean validMove = false; - for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { - RoomTile tile = layout.getTile(x, y); - if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) { - validMove = false; - break; - } + int count = 0; + int maxCount = 8 / nextDirectionOffset; + while (moveDirection != startMoveDirection && !validMove && count < maxCount) { + count++; + if (moveDirection == null) { + moveDirection = startMoveDirection; + } + RoomLayout layout = room.getLayout(); + if (layout == null) return false; - THashSet itemsAtNewTile = room.getItemsAt(tile); - if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { - validMove = false; - break; - } + RoomTile newTile = layout.getTile( + (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), + (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) + ); - ArrayList>> tileItems = new ArrayList<>(rectangle.width * rectangle.height); - tileItems.add(Pair.create(tile, itemsAtNewTile)); - if (!item.canStackAt(room, tileItems)) { - validMove = false; - break; - } - - HabboItem i = room.getTopItemAt(x, y, item); - if (i != null && !i.getBaseItem().allowStack()) { - validMove = false; - break; - } - - offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); - - tilesToUpdate.add(tile); - } - } - if (item.getZ() + offset > 40) { - offset = 40 - item.getZ(); + if (newTile != null) { + boolean hasHabbos = false; + for (Habbo habbo : room.getHabbosAt(newTile)) { + hasHabbos = true; + WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); } - if (validMove) { - if(this.rotation > 0) { - item.setX(newTile.x); - item.setY(newTile.y); - item.setZ(offset); - room.sendComposer(new FloorItemUpdateComposer(item).compose()); - for (RoomTile t : tilesToUpdate) { - room.updateHabbosAt(t.x, t.y); - room.updateBotsAt(t.x, t.y); + if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { + java.awt.Rectangle rectangle = new Rectangle(newTile.x, + newTile.y, + item.getBaseItem().getWidth(), + item.getBaseItem().getLength()); + + double offset = -Short.MAX_VALUE; + validMove = true; + for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { + if (!validMove) { + break; + } + + for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { + RoomTile tile = layout.getTile(x, y); + + if (tile == null || tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED || !tile.getAllowStack()) { + validMove = false; + break; + } + + THashSet itemsAtNewTile = room.getItemsAt(tile); + if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { + validMove = false; + break; + } + + java.util.List tileItems = new ArrayList>>(rectangle.width * rectangle.height); + tileItems.add(Pair.create(tile, itemsAtNewTile)); + if (!item.canStackAt(room, tileItems)) { + validMove = false; + break; + } + + HabboItem i = room.getTopItemAt(x, y, item); + if (i != null && !i.getBaseItem().allowStack()) { + validMove = false; + break; + } + + offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); + + tilesToUpdate.add(tile); } } - else { + if (item.getZ() + offset > 40) { + offset = 40 - item.getZ(); + } + + if (validMove) { room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose()); } } } + if (!validMove) { + moveDirection = RoomUserRotation.fromValue(moveDirection.getValue() + nextDirectionOffset); + } } } } @@ -195,14 +252,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { if (data.length == 4) { try { - this.direction = Integer.parseInt(data[0]); - this.rotation = Integer.parseInt(data[1]); - this.setDelay(Integer.parseInt(data[2])); + this.direction = Integer.valueOf(data[0]); + this.rotation = Integer.valueOf(data[1]); + this.setDelay(Integer.valueOf(data[2])); } catch (Exception e) { } for (String s : data[3].split("\r")) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); + HabboItem item = room.getHabboItem(Integer.valueOf(s)); if (item != null) this.items.add(item); @@ -283,60 +340,4 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { protected long requiredCooldown() { return 100; } - - /** - * Returns a new rotation for an item based on the wired options - * @param item - * @return new rotation - */ - private int getNewRotation(HabboItem item) { - int rotationToAdd = 0; - if (this.rotation == 1) { - rotationToAdd = 2; - } else if (this.rotation == 2) { - rotationToAdd = 6; - } - //Random rotation - else if (this.rotation == 3) { - if (Emulator.getRandom().nextInt(2) == 1) { - rotationToAdd = 2; - } else { - rotationToAdd = 6; - } - } - - return ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); - } - - /** - * Returns the direction of movement based on the wired settings - * @return direction - */ - private RoomUserRotation getMovementDirection() { - RoomUserRotation movemementDirection = RoomUserRotation.NORTH; - if (this.direction == 1) { - movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; - } else if (this.direction == 2) { - if (Emulator.getRandom().nextInt(2) == 1) { - movemementDirection = RoomUserRotation.EAST; - } else { - movemementDirection = RoomUserRotation.WEST; - } - } else if (this.direction == 3) { - if (Emulator.getRandom().nextInt(2) == 1) { - movemementDirection = RoomUserRotation.NORTH; - } else { - movemementDirection = RoomUserRotation.SOUTH; - } - } else if (this.direction == 4) { - movemementDirection = RoomUserRotation.SOUTH; - } else if (this.direction == 5) { - movemementDirection = RoomUserRotation.EAST; - } else if (this.direction == 6) { - movemementDirection = RoomUserRotation.NORTH; - } else if (this.direction == 7) { - movemementDirection = RoomUserRotation.WEST; - } - return movemementDirection; - } } From 34d8d0f8c5754b91cc188a52c9a450f818548f32 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 20:17:54 +0200 Subject: [PATCH 102/153] Adjust vending machine timing --- .../InteractionEffectVendingMachine.java | 24 ++++++++++++++----- .../InteractionVendingMachine.java | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java index 5ea9050e..06897ec4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java @@ -3,18 +3,18 @@ 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.RoomUnitStatus; -import com.eu.habbo.habbohotel.rooms.RoomUserRotation; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction; +import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import com.eu.habbo.util.pathfinding.Rotation; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class InteractionEffectVendingMachine extends InteractionDefault { public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException { @@ -55,7 +55,7 @@ public class InteractionEffectVendingMachine extends InteractionDefault { }); } } else { - if (!tile.isWalkable()) { + if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) { for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { if (t != null && t.isWalkable()) { tile = t; @@ -63,8 +63,20 @@ public class InteractionEffectVendingMachine extends InteractionDefault { } } } + + List onSuccess = new ArrayList<>(); + List onFail = new ArrayList<>(); + + onSuccess.add(() -> Emulator.getThreading().run(() -> { + try { + this.onClick(client, room, objects); + } catch (Exception e) { + e.printStackTrace(); + } + }, 500)); + client.getHabbo().getRoomUnit().setGoalLocation(tile); - Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510); + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail)); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index ed20e804..266bba73 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -87,7 +87,7 @@ public class InteractionVendingMachine extends HabboItem { } catch (Exception e) { e.printStackTrace(); } - }, 150)); + }, 500)); client.getHabbo().getRoomUnit().setGoalLocation(tile); Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail)); From e993a0e95ebe941d3d30de4044d03226e1d152e2 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 21:30:11 +0200 Subject: [PATCH 103/153] Fix wf_blob --- sqlupdates/2_3_0-RC-2_TO_2_3_0.sql | 5 +- .../com/eu/habbo/habbohotel/games/Game.java | 7 +- .../interactions/wired/extra/WiredBlob.java | 118 +++++++++++++----- 3 files changed, 95 insertions(+), 35 deletions(-) diff --git a/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql index 866278ca..d1a5d906 100644 --- a/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql +++ b/sqlupdates/2_3_0-RC-2_TO_2_3_0.sql @@ -1,4 +1,7 @@ ALTER TABLE `users_pets` ADD COLUMN `saddle_item_id` int(11) NULL; -INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!'); \ No newline at end of file +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!'); + +UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob'; +UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2'; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index 943734eb..30d97d03 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -132,8 +132,7 @@ public abstract class Game implements Runnable { } for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { - item.setExtradata("0"); - this.room.updateItem(item); + ((WiredBlob) item).onGameStart(this.room); } } @@ -191,6 +190,10 @@ public abstract class Game implements Runnable { ((InteractionWiredHighscore) item).reloadData(); this.room.updateItem(item); } + + for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) { + ((WiredBlob) item).onGameEnd(this.room); + } } public abstract void run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java index 55e8ca96..b46c81c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java @@ -1,66 +1,120 @@ package com.eu.habbo.habbohotel.items.interactions.wired.extra; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.games.Game; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.GamePlayer; -import com.eu.habbo.habbohotel.games.GameTeam; +import com.eu.habbo.habbohotel.games.GameState; +import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; +import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredEffectType; import java.sql.ResultSet; import java.sql.SQLException; public class WiredBlob extends InteractionDefault { + enum WiredBlobState { + ACTIVE("0"), + USED("1"); + + private String state; + WiredBlobState(String state) { + this.state = state; + } + + public String getState() { + return state; + } + } + + private int POINTS_REWARD = 0; + private boolean RESETS_WITH_GAME = true; + public WiredBlob(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); + + this.parseCustomParams(); } public WiredBlob(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); + + this.parseCustomParams(); + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + + this.setExtradata(WiredBlobState.USED.getState()); + room.updateItem(this); } @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - if (this.getExtradata().equals("0")) { - Habbo habbo = room.getHabbo(roomUnit); + if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return; - if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) { - int points = Emulator.getConfig().getInt("hotel.item.wiredblob." + this.getBaseItem().getName()); + Habbo habbo = room.getHabbo(roomUnit); - if (points == 0) { - Emulator.getConfig().register("hotel.item.wiredblob." + this.getBaseItem().getName(), "3000"); - points = 1; + if (habbo != null) { + GamePlayer player = habbo.getHabboInfo().getGamePlayer(); + + if (player != null) { + player.addScore(this.POINTS_REWARD); + + BattleBanzaiGame battleBanzaiGame = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class); + + if (battleBanzaiGame != null && battleBanzaiGame.getState() != GameState.IDLE) { + battleBanzaiGame.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor()); } - boolean triggered = false; - Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); - - if (game != null) { - GameTeam team = game.getTeamForHabbo(habbo); - - if (team != null) { - team.addTeamScore(points); - triggered = true; - } else { - GamePlayer player = habbo.getHabboInfo().getGamePlayer(); - - if (player != null) { - player.addScore(points); - triggered = true; - } - } - } - - if (triggered) { - this.setExtradata("1"); - room.updateItem(this); - } + this.setExtradata(WiredBlobState.USED.getState()); + room.updateItem(this); } } } + + @Override + public void onClick(GameClient client, Room room, Object[] objects) throws Exception { + if (!this.RESETS_WITH_GAME && objects != null && objects.length == 2 && objects[1].equals(WiredEffectType.TOGGLE_STATE) && room.getGames().stream().anyMatch(game -> game.getState().equals(GameState.RUNNING) || game.getState().equals(GameState.PAUSED))) { + this.setExtradata(this.getExtradata().equals(WiredBlobState.ACTIVE.getState()) ? WiredBlobState.USED.getState() : WiredBlobState.ACTIVE.getState()); + room.updateItem(this); + } + } + + public void onGameStart(Room room) { + if (this.RESETS_WITH_GAME) { + this.setExtradata(WiredBlobState.ACTIVE.getState()); + room.updateItem(this); + } + } + + public void onGameEnd(Room room) { + this.setExtradata(WiredBlobState.USED.getState()); + room.updateItem(this); + } + + private void parseCustomParams() { + String[] params = this.getBaseItem().getCustomParams().split(","); + + if (params.length != 2) { + Emulator.getLogging().logErrorLine("Wired blobs should have customparams with two parameters (points,resetsWithGame)"); + return; + } + + try { + this.POINTS_REWARD = Integer.parseInt(params[0]); + } catch (NumberFormatException e) { + Emulator.getLogging().logErrorLine("Wired blobs should have customparams with the first parameter being the amount of points (number)"); + return; + } + + this.RESETS_WITH_GAME = params[1].equalsIgnoreCase("true"); + } } From fe6679c10966206796790eaf9674fa6c3b45699c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 5 Feb 2020 22:25:54 +0200 Subject: [PATCH 104/153] Retry with walkthrough if non-walkthrough path not found --- .../com/eu/habbo/habbohotel/rooms/RoomLayout.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 258d023b..6d620b2d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -257,8 +257,12 @@ public class RoomLayout { return this.heightmap.replace("\r\n", "\r"); }//re - /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3 public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) { + return this.findPath(oldTile, newTile, goalLocation, roomUnit, false); + } + + /// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3 + public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) { if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) return new LinkedList<>(); LinkedList openList = new LinkedList<>(); @@ -291,7 +295,7 @@ public class RoomLayout { double height = currentAdj.getStackHeight() - current.getStackHeight(); if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; - if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { + if (currentAdj.hasUnits() && ((!isWalktroughRetry && !this.room.isAllowWalkthrough()) || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; @@ -308,6 +312,11 @@ public class RoomLayout { } } // System.out.println("Invalid Path."); + + if (!this.room.isAllowWalkthrough()) { + return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); + } + return new LinkedList<>(); } From ed13fa956773e679b529148b85c457b87a241df0 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 5 Feb 2020 20:52:39 +0000 Subject: [PATCH 105/153] Re-added changes to MoveRotateFurni wired, credits to Skeletor. Tested on habbo and works as intended. --- src/main/java/com/eu/habbo/Emulator.java | 2 +- .../effects/WiredEffectMoveRotateFurni.java | 299 +++++++++--------- 2 files changed, 148 insertions(+), 153 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 6999051a..39e52445 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -40,7 +40,7 @@ public final class Emulator { public static final String ANSI_YELLOW = "\u001B[33m"; - public final static String PREVIEW = "RC-2"; + public final static String PREVIEW = "Stable"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index c83fcad7..5cd5d734 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -39,174 +39,117 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = new THashSet<>(this.items.size()); + // remove items that are no longer in the room + this.items.removeIf( item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); + THashSet tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10)); - for (HabboItem item : this.items) { - if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } - for (HabboItem item : this.items) { //Handle rotation - int rotationToAdd = 0; if (this.rotation > 0) { tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - if (this.rotation == 1) { - rotationToAdd = 2; - } else if (this.rotation == 2) { - rotationToAdd = 6; - } - //Random rotation - else if (this.rotation == 3) { - if (Emulator.getRandom().nextInt(2) == 1) { - rotationToAdd = 2; - } else { - rotationToAdd = 6; - } - } - } + int newRotation = this.getNewRotation(item); - int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); - //Verify if rotation result in a valid position - FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); - if (rotationToAdd > 0 && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || - rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) - { - item.setRotation(newRotation); - - if (this.direction == 0) { - tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - room.sendComposer(new FloorItemUpdateComposer(item).compose()); - for (RoomTile t : tilesToUpdate) { - room.updateHabbosAt(t.x, t.y); - room.updateBotsAt(t.x, t.y); - } - } - } - - if (this.direction > 0) { - int nextDirectionOffset = 0; - RoomUserRotation startMoveDirection = RoomUserRotation.NORTH; - RoomUserRotation moveDirection = null; - if (this.direction == 1) { - startMoveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; - nextDirectionOffset = 2; - } else if (this.direction == 2) { - if (Emulator.getRandom().nextInt(2) == 1) { - startMoveDirection = RoomUserRotation.EAST; - nextDirectionOffset = 4; - } else { - startMoveDirection = RoomUserRotation.WEST; - nextDirectionOffset = 4; - } - } else if (this.direction == 3) { - if (Emulator.getRandom().nextInt(2) == 1) { - startMoveDirection = RoomUserRotation.NORTH; - nextDirectionOffset = 4; - } else { - startMoveDirection = RoomUserRotation.SOUTH; - nextDirectionOffset = 4; - } - } else if (this.direction == 4) { - startMoveDirection = RoomUserRotation.SOUTH; - nextDirectionOffset = 8; - } else if (this.direction == 5) { - startMoveDirection = RoomUserRotation.EAST; - nextDirectionOffset = 8; - } else if (this.direction == 6) { - startMoveDirection = RoomUserRotation.NORTH; - nextDirectionOffset = 8; - } else if (this.direction == 7) { - startMoveDirection = RoomUserRotation.WEST; - nextDirectionOffset = 8; - } - - boolean validMove = false; - - int count = 0; - int maxCount = 8 / nextDirectionOffset; - while (moveDirection != startMoveDirection && !validMove && count < maxCount) { - count++; - if (moveDirection == null) { - moveDirection = startMoveDirection; - } - RoomLayout layout = room.getLayout(); - if (layout == null) return false; - - RoomTile newTile = layout.getTile( - (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), - (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) - ); - - if (newTile != null) { - boolean hasHabbos = false; - for (Habbo habbo : room.getHabbosAt(newTile)) { - hasHabbos = true; - WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); + //Verify if rotation result in a valid position + FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation); + if (item.getRotation() != newRotation && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) || + rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) + { + item.setRotation(newRotation); + if(this.direction == 0) { + tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + room.sendComposer(new FloorItemUpdateComposer(item).compose()); + for (RoomTile t : tilesToUpdate) { + room.updateHabbosAt(t.x, t.y); + room.updateBotsAt(t.x, t.y); } + } + } + } - if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { - java.awt.Rectangle rectangle = new Rectangle(newTile.x, - newTile.y, - item.getBaseItem().getWidth(), - item.getBaseItem().getLength()); + //handle movement + if (this.direction > 0) { + RoomUserRotation moveDirection = this.getMovementDirection(); + boolean validMove = false; + RoomLayout layout = room.getLayout(); + if (layout == null) return false; - double offset = -Short.MAX_VALUE; - validMove = true; - for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { - if (!validMove) { + RoomTile newTile = layout.getTile( + (short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))), + (short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0))) + ); + + if (newTile != null) { + boolean hasHabbos = false; + for (Habbo habbo : room.getHabbosAt(newTile)) { + hasHabbos = true; + WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item}); + } + + if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE) { + java.awt.Rectangle rectangle = new Rectangle(newTile.x, + newTile.y, + item.getBaseItem().getWidth(), + item.getBaseItem().getLength()); + + double offset = -Short.MAX_VALUE; + validMove = true; + for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) { + if (!validMove) { + break; + } + + for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { + RoomTile tile = layout.getTile(x, y); + if (tile == null || tile.state == RoomTileState.INVALID || !tile.getAllowStack()) { + validMove = false; break; } - for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) { - RoomTile tile = layout.getTile(x, y); + THashSet itemsAtNewTile = room.getItemsAt(tile); + if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { + validMove = false; + break; + } - if (tile == null || tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED || !tile.getAllowStack()) { - validMove = false; - break; - } + ArrayList>> tileItems = new ArrayList<>(rectangle.width * rectangle.height); + tileItems.add(Pair.create(tile, itemsAtNewTile)); + if (!item.canStackAt(room, tileItems)) { + validMove = false; + break; + } - THashSet itemsAtNewTile = room.getItemsAt(tile); - if (item instanceof InteractionRoller && !itemsAtNewTile.isEmpty()) { - validMove = false; - break; - } + HabboItem i = room.getTopItemAt(x, y, item); + if (i != null && !i.getBaseItem().allowStack()) { + validMove = false; + break; + } - java.util.List tileItems = new ArrayList>>(rectangle.width * rectangle.height); - tileItems.add(Pair.create(tile, itemsAtNewTile)); - if (!item.canStackAt(room, tileItems)) { - validMove = false; - break; - } + offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); - HabboItem i = room.getTopItemAt(x, y, item); - if (i != null && !i.getBaseItem().allowStack()) { - validMove = false; - break; - } + tilesToUpdate.add(tile); + } + } + if (item.getZ() + offset > 40) { + offset = 40 - item.getZ(); + } - offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset); - - tilesToUpdate.add(tile); + if (validMove) { + if(this.rotation > 0) { + item.setX(newTile.x); + item.setY(newTile.y); + item.setZ(offset); + room.sendComposer(new FloorItemUpdateComposer(item).compose()); + for (RoomTile t : tilesToUpdate) { + room.updateHabbosAt(t.x, t.y); + room.updateBotsAt(t.x, t.y); } } - if (item.getZ() + offset > 40) { - offset = 40 - item.getZ(); - } - - if (validMove) { + else { room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose()); } } } - if (!validMove) { - moveDirection = RoomUserRotation.fromValue(moveDirection.getValue() + nextDirectionOffset); - } } } } @@ -252,14 +195,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { if (data.length == 4) { try { - this.direction = Integer.valueOf(data[0]); - this.rotation = Integer.valueOf(data[1]); - this.setDelay(Integer.valueOf(data[2])); + this.direction = Integer.parseInt(data[0]); + this.rotation = Integer.parseInt(data[1]); + this.setDelay(Integer.parseInt(data[2])); } catch (Exception e) { } for (String s : data[3].split("\r")) { - HabboItem item = room.getHabboItem(Integer.valueOf(s)); + HabboItem item = room.getHabboItem(Integer.parseInt(s)); if (item != null) this.items.add(item); @@ -336,8 +279,60 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { return true; } - @Override - protected long requiredCooldown() { - return 100; + + /** + * Returns a new rotation for an item based on the wired options + * @param item + * @return new rotation + */ + private int getNewRotation(HabboItem item) { + int rotationToAdd = 0; + if (this.rotation == 1) { + rotationToAdd = 2; + } else if (this.rotation == 2) { + rotationToAdd = 6; + } + //Random rotation + else if (this.rotation == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { + rotationToAdd = 2; + } else { + rotationToAdd = 6; + } + } + + return ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8); } -} + + /** + * Returns the direction of movement based on the wired settings + * @return direction + */ + private RoomUserRotation getMovementDirection() { + RoomUserRotation movemementDirection = RoomUserRotation.NORTH; + if (this.direction == 1) { + movemementDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length / 2) * 2]; + } else if (this.direction == 2) { + if (Emulator.getRandom().nextInt(2) == 1) { + movemementDirection = RoomUserRotation.EAST; + } else { + movemementDirection = RoomUserRotation.WEST; + } + } else if (this.direction == 3) { + if (Emulator.getRandom().nextInt(2) == 1) { + movemementDirection = RoomUserRotation.NORTH; + } else { + movemementDirection = RoomUserRotation.SOUTH; + } + } else if (this.direction == 4) { + movemementDirection = RoomUserRotation.SOUTH; + } else if (this.direction == 5) { + movemementDirection = RoomUserRotation.EAST; + } else if (this.direction == 6) { + movemementDirection = RoomUserRotation.NORTH; + } else if (this.direction == 7) { + movemementDirection = RoomUserRotation.WEST; + } + return movemementDirection; + } +} \ No newline at end of file From 653f6113230223ed65294edcda75609a2520271b Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Wed, 5 Feb 2020 21:23:27 +0000 Subject: [PATCH 106/153] Fix for height in MoveRotateFurni - Credits to Skeletor for the overhaul. --- .../interactions/wired/effects/WiredEffectMoveRotateFurni.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 5cd5d734..ae37a0f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -138,7 +138,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect { if(this.rotation > 0) { item.setX(newTile.x); item.setY(newTile.y); - item.setZ(offset); + item.setZ(item.getZ() + offset); room.sendComposer(new FloorItemUpdateComposer(item).compose()); for (RoomTile t : tilesToUpdate) { room.updateHabbosAt(t.x, t.y); From 0e53d703b3eff1f75275fc747753aae10d7ae305 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 00:56:40 +0200 Subject: [PATCH 107/153] Fix vending machine behaviour --- .../InteractionEffectVendingMachine.java | 58 +---------- .../InteractionVendingMachine.java | 99 ++++++++++++++++--- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 10 ++ .../rooms/users/RoomUserWalkEvent.java | 3 + .../runnables/RoomUnitWalkToLocation.java | 12 +-- 5 files changed, 108 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java index 06897ec4..eccba568 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; @@ -16,7 +17,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class InteractionEffectVendingMachine extends InteractionDefault { +public class InteractionEffectVendingMachine extends InteractionVendingMachine { public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); @@ -28,58 +29,7 @@ public class InteractionEffectVendingMachine extends InteractionDefault { } @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - - if (client != null) { - RoomTile tile = getSquareInFront(room.getLayout(), this); - - if (tile != null) { - if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { - if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) { - room.updateHabbo(client.getHabbo()); - if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT)) { - client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]); - client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); - } - this.setExtradata("1"); - room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose()); - Emulator.getThreading().run(this, 1000); - HabboItem instance = this; - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - room.giveEffect(client.getHabbo().getRoomUnit(), instance.getBaseItem().getRandomVendingItem(), 30); - } - }); - } - } else { - if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) { - for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) { - if (t != null && t.isWalkable()) { - tile = t; - break; - } - } - } - - List onSuccess = new ArrayList<>(); - List onFail = new ArrayList<>(); - - onSuccess.add(() -> Emulator.getThreading().run(() -> { - try { - this.onClick(client, room, objects); - } catch (Exception e) { - e.printStackTrace(); - } - }, 500)); - - client.getHabbo().getRoomUnit().setGoalLocation(tile); - Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail)); - } - } - } + public void giveVendingMachineItem(Habbo habbo, Room room) { + room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getRandomVendingItem(), 30); } - } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 266bba73..50d66b91 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -4,13 +4,13 @@ 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.*; +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.rooms.items.FloorItemUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; -import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; import com.eu.habbo.util.pathfinding.Rotation; @@ -18,6 +18,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutionException; public class InteractionVendingMachine extends HabboItem { public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException { @@ -52,21 +53,25 @@ public class InteractionVendingMachine extends HabboItem { if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) { if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) { room.updateHabbo(client.getHabbo()); - client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]); + this.rotateToMachine(client.getHabbo().getRoomUnit()); client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE); room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); } - this.setExtradata("1"); - room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose()); - Emulator.getThreading().run(this, 1000); - Emulator.getThreading().run(new RoomUnitGiveHanditem(client.getHabbo().getRoomUnit(), room, this.getBaseItem().getRandomVendingItem())); - - if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); - if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) - room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); + + this.setExtradata("1"); + room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose()); + + Emulator.getThreading().run(() -> { + Emulator.getThreading().run(this, 1000); + this.giveVendingMachineItem(client.getHabbo(), room); + + if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) + room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); + if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) + room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + }, 500); } } else { if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) { @@ -81,13 +86,42 @@ public class InteractionVendingMachine extends HabboItem { List onSuccess = new ArrayList<>(); List onFail = new ArrayList<>(); - onSuccess.add(() -> Emulator.getThreading().run(() -> { + RoomTile finalTile = tile; + onSuccess.add(() -> { + this.setExtradata("1"); + room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose()); + try { - this.onClick(client, room, objects); + super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"}); } catch (Exception e) { e.printStackTrace(); } - }, 500)); + + Emulator.getThreading().run(() -> { + Runnable procedure = () -> { + if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) { + this.rotateToMachine(client.getHabbo().getRoomUnit()); + room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); + } + + try { + Emulator.getThreading().run(() -> { + Emulator.getThreading().run(this, 1000); + this.giveVendingMachineItem(client.getHabbo(), room); + + if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) + room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1); + if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) + room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1); + }, 500).get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + }; + + client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(procedure, 300)); + }, 250); + }); client.getHabbo().getRoomUnit().setGoalLocation(tile); Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail)); @@ -136,4 +170,41 @@ public class InteractionVendingMachine extends HabboItem { public boolean isUsable() { return true; } + + private void rotateToMachine(RoomUnit unit) { + RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())]; + boolean onlyHead = false; + + switch (unit.getBodyRotation()) { + case NORTH_EAST: + if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.EAST)) + onlyHead = true; + break; + + case NORTH_WEST: + if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.WEST)) + onlyHead = true; + break; + + case SOUTH_EAST: + if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.EAST)) + onlyHead = true; + break; + + case SOUTH_WEST: + if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.WEST)) + onlyHead = true; + break; + } + + if (onlyHead) { + unit.setHeadRotation(rotation); + } else { + unit.setRotation(rotation); + } + } + + public void giveVendingMachineItem(Habbo habbo, Room room) { + Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem())); + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 348fddad..47489f78 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -27,6 +27,7 @@ import gnu.trove.set.hash.THashSet; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledFuture; public class RoomUnit { private final ConcurrentHashMap status; @@ -65,6 +66,7 @@ public class RoomUnit { private int walkTimeOut; private int effectId; private int effectEndTimestamp; + private ScheduledFuture moveBlockingTask; private int idleTimer; private Room room; @@ -768,4 +770,12 @@ public class RoomUnit { .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) .min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null); } + + public ScheduledFuture getMoveBlockingTask() { + return moveBlockingTask; + } + + public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) { + this.moveBlockingTask = moveBlockingTask; + } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 815fe3e0..920a4d77 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -117,6 +117,9 @@ public class RoomUserWalkEvent extends MessageHandler { // This is where we set the end location and begin finding a path if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { + if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get(); + System.out.println(roomUnit.getMoveBlockingTask()); + roomUnit.setGoalLocation(tile); } } else { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java index cb3e2935..21356e91 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -29,17 +29,17 @@ public class RoomUnitWalkToLocation implements Runnable { return; } - if (!this.walker.getGoal().equals(this.goalTile)) { - onFail(); - return; - } - if (this.walker.getCurrentLocation().equals(this.goalTile)) { onSuccess(); return; } - Emulator.getThreading().run(this, 500); + if (!this.walker.getGoal().equals(this.goalTile)) { + onFail(); + return; + } + + Emulator.getThreading().run(this, 250); } private void onSuccess() { From 4389d7e18fa605792d30cbf4d0c2f493ff5dcfd0 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 01:01:39 +0200 Subject: [PATCH 108/153] Remove unnecessary console log --- .../habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 920a4d77..c14d6f66 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -118,7 +118,6 @@ public class RoomUserWalkEvent extends MessageHandler { // This is where we set the end location and begin finding a path if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get(); - System.out.println(roomUnit.getMoveBlockingTask()); roomUnit.setGoalLocation(tile); } From b87cbd398bcd780a1e02509720b6fd29adca083a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 01:06:49 +0200 Subject: [PATCH 109/153] Do not cancel navigation if overriding path is non-existent --- .../java/com/eu/habbo/habbohotel/rooms/RoomLayout.java | 2 +- .../java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 6d620b2d..3f99af34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -317,7 +317,7 @@ public class RoomLayout { return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); } - return new LinkedList<>(); + return null; } private RoomTile findTile(List tiles, short x, short y) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 47489f78..a876a4d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -177,6 +177,9 @@ public class RoomUnit { } Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); + + if (peekPath == null) peekPath = new LinkedList<>(); + if (peekPath.size() >= 3) { if (path.isEmpty()) return true; @@ -543,10 +546,9 @@ public class RoomUnit { public void findPath() { - if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) - { - - this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); + if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) { + Deque path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); + if (path != null) this.path = path; } } From df8f80f9cb55fdcb32152e9cb61784823a9ff6e5 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 01:16:51 +0200 Subject: [PATCH 110/153] Add vending machines without sides --- .../habbo/habbohotel/items/ItemManager.java | 1 + .../InteractionNoSidesVendingMachine.java | 24 +++++++++++++++++++ .../InteractionVendingMachine.java | 6 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.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 cde2f0e3..4e6969e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -178,6 +178,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class)); this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class)); this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class)); + this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class)); this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class)); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java new file mode 100644 index 00000000..367d500e --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java @@ -0,0 +1,24 @@ +package com.eu.habbo.habbohotel.items.interactions; + +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.users.Habbo; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class InteractionNoSidesVendingMachine extends InteractionVendingMachine { + public InteractionNoSidesVendingMachine(ResultSet set, Item baseItem) throws SQLException { + super(set, baseItem); + } + + public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { + super(id, userId, item, extradata, limitedStack, limitedSells); + } + + @Override + public RoomTile getRequiredTile(Habbo habbo, Room room) { + return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 50d66b91..4ddc40bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -46,7 +46,7 @@ public class InteractionVendingMachine extends HabboItem { super.onClick(client, room, objects); if (client != null) { - RoomTile tile = getSquareInFront(room.getLayout(), this); + RoomTile tile = this.getRequiredTile(client.getHabbo(), room); if (tile != null) { if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) { @@ -207,4 +207,8 @@ public class InteractionVendingMachine extends HabboItem { public void giveVendingMachineItem(Habbo habbo, Room room) { Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem())); } + + public RoomTile getRequiredTile(Habbo habbo, Room room) { + return getSquareInFront(room.getLayout(), this); + } } From 867e5cf7e636150c8dd40cf786c62dec111d6582 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 6 Feb 2020 14:01:21 +0200 Subject: [PATCH 111/153] Organize pet-related item interactions --- src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java | 1 + .../interactions/{ => pets}/InteractionMonsterPlantSeed.java | 2 +- .../items/interactions/{ => pets}/InteractionNest.java | 2 +- .../interactions/{ => pets}/InteractionPetBreedingNest.java | 2 +- .../items/interactions/{ => pets}/InteractionPetDrink.java | 3 ++- .../items/interactions/{ => pets}/InteractionPetFood.java | 3 ++- .../items/interactions/{ => pets}/InteractionPetToy.java | 3 ++- 7 files changed, 10 insertions(+), 6 deletions(-) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{ => pets}/InteractionMonsterPlantSeed.java (97%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{ => pets}/InteractionNest.java (97%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{ => pets}/InteractionPetBreedingNest.java (99%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{ => pets}/InteractionPetDrink.java (94%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{ => pets}/InteractionPetFood.java (94%) rename src/main/java/com/eu/habbo/habbohotel/items/interactions/{ => pets}/InteractionPetToy.java (95%) 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 4e6969e2..dbfea5f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -38,6 +38,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.Interaction import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole; import com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate.InteractionRollerskateField; +import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemHead; import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemLegs; import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java similarity index 97% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java index f9ac09da..96e79004 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterPlantSeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.items.interactions; +package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java similarity index 97% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java index 36fb719a..d7293389 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.items.interactions; +package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java similarity index 99% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java index 48049fee..16d219a9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.items.interactions; +package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java similarity index 94% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index b0a3131f..a18ada6b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -1,8 +1,9 @@ -package com.eu.habbo.habbohotel.items.interactions; +package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java similarity index 94% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java index 07e3fd90..8f2dd02c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetFood.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java @@ -1,7 +1,8 @@ -package com.eu.habbo.habbohotel.items.interactions; +package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java similarity index 95% rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index f70540b8..680bae5a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -1,7 +1,8 @@ -package com.eu.habbo.habbohotel.items.interactions; +package com.eu.habbo.habbohotel.items.interactions.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; From 37b51db2b6ba9e3cf4635d784a8cd6f29c099acd Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 6 Feb 2020 16:50:22 +0000 Subject: [PATCH 112/153] Pushed version as RC-3, requires testing before pushing to stable. --- src/main/java/com/eu/habbo/Emulator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 39e52445..209ab029 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -40,7 +40,7 @@ public final class Emulator { public static final String ANSI_YELLOW = "\u001B[33m"; - public final static String PREVIEW = "Stable"; + public final static String PREVIEW = "RC-3"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = From aec26262961d90207eaac792a5a67ddfa7457c90 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Thu, 6 Feb 2020 23:05:16 +0000 Subject: [PATCH 113/153] WIP: Fix WiredEffectTeleport --- .../wired/effects/WiredEffectTeleport.java | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index 729c50e4..2cbe93b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -63,6 +63,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { for (RoomTile optionalTile : optionalTiles) { if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED) { alternativeTile = optionalTile; + break; } } @@ -139,30 +140,13 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } + this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() + || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); if (!this.items.isEmpty()) { - int i = Emulator.getRandom().nextInt(this.items.size()) + 1; - int j = 1; - - int tryCount = 0; - while (tryCount < this.items.size()) { - tryCount++; - HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size()); - - teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY())); - break; - - } + int i = Emulator.getRandom().nextInt(this.items.size()); + HabboItem item = this.items.get(i); + teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY())); return true; } @@ -220,6 +204,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override protected long requiredCooldown() { - return 0; + return 50L; } } From 43f0e54209553742e1f2ee273d198812ce64fa9c Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Sat, 8 Feb 2020 11:31:56 +0000 Subject: [PATCH 114/153] Fix issue with WiredEffectTeleport. Credits to Beny. --- .../wired/effects/WiredEffectTeleport.java | 2 +- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 1 + .../habbo/habbohotel/wired/WiredHandler.java | 21 ++++++++----------- .../threading/runnables/RoomUnitTeleport.java | 2 ++ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index 2cbe93b4..965ed802 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -42,7 +42,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { - if (roomUnit == null || tile == null) + if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting) return; Room room = roomUnit.getRoom(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index a876a4d4..b85f8946 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; public class RoomUnit { + public boolean isWiredTeleporting = false; private final ConcurrentHashMap status; private final THashMap cacheable; public boolean canRotate = true; 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 a88ff69f..cc0c9ac7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -194,19 +194,16 @@ public class WiredHandler { if (effect != null && effect.canExecute(millis)) { executed = true; if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - if (room.isLoaded()) { - try { - if (!effect.execute(roomUnit, room, stuff)) return; - effect.setCooldown(millis); - } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); - } - - effect.activateBox(room); + Emulator.getThreading().run(() -> { + if (room.isLoaded()) { + try { + if (!effect.execute(roomUnit, room, stuff)) return; + effect.setCooldown(millis); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); } + + effect.activateBox(room); } }, effect.getDelay() * 500); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 3a255ffb..f71173c3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -27,6 +27,7 @@ public class RoomUnitTeleport implements Runnable { this.y = y; this.z = z; this.newEffect = newEffect; + roomUnit.isWiredTeleporting = true; } @Override @@ -53,6 +54,7 @@ public class RoomUnitTeleport implements Runnable { ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose(); this.roomUnit.setLocation(t); this.room.sendComposer(teleportMessage); + roomUnit.isWiredTeleporting = false; this.room.updateHabbosAt(t.x, t.y); this.room.updateBotsAt(t.x, t.y); From 5c78088726e7583616f64a4f27e5d60b4a957717 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Sat, 8 Feb 2020 07:02:34 -0500 Subject: [PATCH 115/153] WiredEffectTeleport Vulnerability Fix --- .../wired/effects/WiredEffectTeleport.java | 32 +++++-------------- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 1 + .../habbo/habbohotel/wired/WiredHandler.java | 21 ++++++------ .../threading/runnables/RoomUnitTeleport.java | 2 ++ 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index 729c50e4..965ed802 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -42,7 +42,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { - if (roomUnit == null || tile == null) + if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting) return; Room room = roomUnit.getRoom(); @@ -63,6 +63,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { for (RoomTile optionalTile : optionalTiles) { if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED) { alternativeTile = optionalTile; + break; } } @@ -139,30 +140,13 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) { - THashSet items = new THashSet<>(); - - for (HabboItem item : this.items) { - if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null) - items.add(item); - } - - for (HabboItem item : items) { - this.items.remove(item); - } + this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() + || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null); if (!this.items.isEmpty()) { - int i = Emulator.getRandom().nextInt(this.items.size()) + 1; - int j = 1; - - int tryCount = 0; - while (tryCount < this.items.size()) { - tryCount++; - HabboItem item = this.items.get((tryCount - 1 + i) % this.items.size()); - - teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY())); - break; - - } + int i = Emulator.getRandom().nextInt(this.items.size()); + HabboItem item = this.items.get(i); + teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY())); return true; } @@ -220,6 +204,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect { @Override protected long requiredCooldown() { - return 0; + return 50L; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index a876a4d4..b85f8946 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; public class RoomUnit { + public boolean isWiredTeleporting = false; private final ConcurrentHashMap status; private final THashMap cacheable; public boolean canRotate = true; 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 a88ff69f..cc0c9ac7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -194,19 +194,16 @@ public class WiredHandler { if (effect != null && effect.canExecute(millis)) { executed = true; if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { - Emulator.getThreading().run(new Runnable() { - @Override - public void run() { - if (room.isLoaded()) { - try { - if (!effect.execute(roomUnit, room, stuff)) return; - effect.setCooldown(millis); - } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); - } - - effect.activateBox(room); + Emulator.getThreading().run(() -> { + if (room.isLoaded()) { + try { + if (!effect.execute(roomUnit, room, stuff)) return; + effect.setCooldown(millis); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); } + + effect.activateBox(room); } }, effect.getDelay() * 500); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 3a255ffb..f71173c3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -27,6 +27,7 @@ public class RoomUnitTeleport implements Runnable { this.y = y; this.z = z; this.newEffect = newEffect; + roomUnit.isWiredTeleporting = true; } @Override @@ -53,6 +54,7 @@ public class RoomUnitTeleport implements Runnable { ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose(); this.roomUnit.setLocation(t); this.room.sendComposer(teleportMessage); + roomUnit.isWiredTeleporting = false; this.room.updateHabbosAt(t.x, t.y); this.room.updateBotsAt(t.x, t.y); From d645465da891f044efefce6262091d397b1d2e9a Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 8 Feb 2020 18:14:47 +0200 Subject: [PATCH 116/153] Remove time from creation date in profile composer --- .../eu/habbo/messages/outgoing/users/UserProfileComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java index 6a9cdf33..eecb7858 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java @@ -46,7 +46,7 @@ public class UserProfileComposer extends MessageComposer { this.response.appendString(this.habboInfo.getUsername()); this.response.appendString(this.habboInfo.getLook()); this.response.appendString(this.habboInfo.getMotto()); - this.response.appendString(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date(this.habboInfo.getAccountCreated() * 1000L))); + this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.habboInfo.getAccountCreated() * 1000L))); int achievementScore = 0; if (this.habbo != null) { From 0cb98867eef707eefc18d7b5ffc0e8e6465fa72d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 8 Feb 2020 18:17:02 +0200 Subject: [PATCH 117/153] Fix NPE in Game --- .../com/eu/habbo/habbohotel/games/Game.java | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index 30d97d03..b64d8292 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -91,8 +91,11 @@ public abstract class Game implements Runnable { GameTeam team = this.getTeamForHabbo(habbo); if (team != null && team.isMember(habbo)) { - team.removeMember(habbo.getHabboInfo().getGamePlayer()); - habbo.getHabboInfo().getGamePlayer().reset(); + if (habbo.getHabboInfo().getGamePlayer() != null) { + team.removeMember(habbo.getHabboInfo().getGamePlayer()); + habbo.getHabboInfo().getGamePlayer().reset(); + } + habbo.getHabboInfo().setCurrentGame(null); habbo.getHabboInfo().setGamePlayer(null); habbo.getClient().sendResponse(new GuideSessionPartnerIsPlayingComposer(false)); @@ -101,23 +104,6 @@ public abstract class Game implements Runnable { } } } - - /* - boolean deleteGame = true; - for (GameTeam team : this.teams.values()) - { - if (team.getMembers().size() > 0 ) - { - deleteGame = false; - break; - } - } - - if (deleteGame) - { - this.room.deleteGame(this); - } - */ } From 359a980c676c3c030ab83eada228e2c28c3eee2f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 8 Feb 2020 18:22:06 +0200 Subject: [PATCH 118/153] Fix imports and add overriding tiles --- .../com/eu/habbo/habbohotel/pets/PetData.java | 8 ++--- .../eu/habbo/habbohotel/pets/PetManager.java | 8 ++--- .../habbohotel/pets/actions/ActionBreed.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 15 +++++++-- .../habbohotel/rooms/RoomSpecialTypes.java | 4 +++ .../eu/habbo/habbohotel/users/HabboItem.java | 33 ++++++++++++++++--- .../rooms/items/ToggleFloorItemEvent.java | 3 +- .../rooms/pets/ConfirmPetBreedingEvent.java | 2 +- .../rooms/pets/StopBreedingEvent.java | 2 +- .../threading/runnables/PetEatAction.java | 2 +- 10 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java index 8771b7b3..1eae8a4b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetData.java @@ -2,10 +2,10 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionNest; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetDrink; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetToy; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index d4079923..7335963d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -3,10 +3,10 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.items.interactions.InteractionNest; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetDrink; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetToy; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy; import com.eu.habbo.habbohotel.pets.actions.*; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java index 180474e7..83ec6207 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionBreed.java @@ -1,6 +1,6 @@ package com.eu.habbo.habbohotel.pets.actions; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetAction; import com.eu.habbo.habbohotel.pets.PetTasks; 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 29a7748c..57e2a6d3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -19,6 +19,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.Interaction import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; @@ -576,10 +580,10 @@ public class Room implements Comparable, ISerialize, Runnable { if (lowestItem == null || lowestItem.getZ() < item.getZ()) { lowestItem = item; - result = this.checkStateForItem(lowestItem); + result = this.checkStateForItem(lowestItem, tile); } else if (lowestItem.getZ() == item.getZ()) { if (result == RoomTileState.OPEN) { - result = this.checkStateForItem(item); + result = this.checkStateForItem(item, tile); } } } @@ -589,7 +593,7 @@ public class Room implements Comparable, ISerialize, Runnable { return result; } - private RoomTileState checkStateForItem(HabboItem item) { + private RoomTileState checkStateForItem(HabboItem item, RoomTile tile) { RoomTileState result = RoomTileState.BLOCKED; if (item.isWalkable()) { @@ -604,6 +608,11 @@ public class Room implements Comparable, ISerialize, Runnable { result = RoomTileState.LAY; } + RoomTileState overriddenState = item.getOverrideTileState(tile, this); + if (overriddenState != null) { + result = overriddenState; + } + return result; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java index 8f340378..0b912776 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -15,6 +15,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.Int import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate; import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredEffectType; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index 4fe8a220..f689c504 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -10,10 +10,7 @@ import com.eu.habbo.habbohotel.items.IEventTriggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomLayout; -import com.eu.habbo.habbohotel.rooms.RoomTile; -import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -25,12 +22,14 @@ import gnu.trove.set.hash.THashSet; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.math3.util.Pair; +import java.awt.*; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Deque; import java.util.List; public abstract class HabboItem implements Runnable, IEventTriggers { @@ -487,4 +486,30 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } public boolean invalidatesToRoomKick() { return false; } + + public List getOccupyingTiles(RoomLayout layout) { + List tiles = new ArrayList<>(); + + Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()); + + for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { + for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { + tiles.add(layout.getTile((short) i, (short) j)); + } + } + + return tiles; + } + + public RoomTile getOverrideGoalTile(RoomUnit unit, Room room, RoomTile tile) { + return tile; + } + + public RoomTileState getOverrideTileState(RoomTile tile, Room room) { + return null; + } + + public boolean canOverrideTile(RoomUnit unit, Room room, RoomTile tile) { + return false; + } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java index c64d111e..e9e04c73 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionDice; -import com.eu.habbo.habbohotel.items.interactions.InteractionMonsterPlantSeed; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed; import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.rooms.Room; @@ -12,7 +12,6 @@ import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -import gnu.trove.set.hash.THashSet; public class ToggleFloorItemEvent extends MessageHandler { @Override diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java index 668ee248..13a1e200 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ConfirmPetBreedingEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.incoming.rooms.pets; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java index 4370231e..5d19000d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/StopBreedingEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.incoming.rooms.pets; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetBreedingNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; diff --git a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java index 28c0cf96..331e5949 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/PetEatAction.java @@ -2,7 +2,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; -import com.eu.habbo.habbohotel.items.interactions.InteractionPetFood; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; import com.eu.habbo.habbohotel.pets.GnomePet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetTasks; From 952fd8bd10036fe9827b51078b0580eb90d18f74 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 8 Feb 2020 18:23:46 +0200 Subject: [PATCH 119/153] Add tile data to onWalkOn and onWalkOff events and fix NPE in RoomUnit --- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index b85f8946..7eb7278b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -28,6 +28,7 @@ import gnu.trove.set.hash.THashSet; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; +import java.util.stream.Collectors; public class RoomUnit { public boolean isWiredTeleporting = false; @@ -290,7 +291,7 @@ public class RoomUnit { if (item != null) { if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) { if (item.canWalkOn(this, room, null)) { - item.onWalkOn(this, room, null); + item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next}); } else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) { this.setRotation(oldRotation); this.tilesWalked--; @@ -305,7 +306,7 @@ public class RoomUnit { return false; } } else { - item.onWalk(this, room, null); + item.onWalk(this, room, new Object[]{this.getCurrentLocation(), next}); } zHeight += item.getZ(); @@ -714,6 +715,9 @@ public class RoomUnit { public boolean canOverrideTile(RoomTile tile) { if (tile == null || room == null || room.getLayout() == null) return false; + if (room.getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, room, tile))) + return true; + int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1; return this.overridableTiles.contains(tileIndex); } @@ -726,6 +730,8 @@ public class RoomUnit { } public void removeOverrideTile(RoomTile tile) { + if (room == null || room.getLayout() == null) return; + int tileIndex = (room.getLayout().getMapSizeY() * tile.y) + tile.x + 1; this.overridableTiles.remove(tileIndex); } @@ -750,6 +756,10 @@ public class RoomUnit { return topItem == null || (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); } + public RoomTile getClosestTile(List tiles) { + return tiles.stream().min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null); + } + public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) { RoomTile baseTile = room.getLayout().getTile(x, y); @@ -768,10 +778,12 @@ public class RoomUnit { rotations.add(RoomUserRotation.SOUTH_WEST.getValue()); } - return rotations.stream() - .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) - .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) - .min(Comparator.comparingDouble(a -> a.distance(this.getCurrentLocation()))).orElse(null); + return this.getClosestTile( + rotations.stream() + .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) + .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) + .collect(Collectors.toList()) + ); } public ScheduledFuture getMoveBlockingTask() { From e596b1231d6c3c09d923f83e8202307e34fc0938 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sat, 8 Feb 2020 18:25:44 +0200 Subject: [PATCH 120/153] Fix NPE in Room --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 3 +++ 1 file changed, 3 insertions(+) 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 57e2a6d3..326fb66f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2377,6 +2377,9 @@ public class Room implements Comparable, ISerialize, Runnable { } public HabboItem getHabboItem(int id) { + if (this.roomItems == null || this.roomSpecialTypes == null) + return null; // room not loaded completely + HabboItem item; synchronized (this.roomItems) { item = this.roomItems.get(id); From b3a88c7d107d2e713899e967ff649a343554d199 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Tue, 11 Feb 2020 11:44:44 +0200 Subject: [PATCH 121/153] Fix moodlight saving scripting detection --- .../incoming/rooms/items/MoodLightSaveSettingsEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index e953255c..7d3d39f2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -33,7 +33,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { return; } - if (brightness > 0xFF || brightness <= (0.3 * 0xFF)) { + if (brightness > 0xFF || brightness < (0.3 * 0xFF)) { ScripterManager.scripterDetected(this.client, "User tried to set a moodlight's brightness to out-of-bounds ([76, 255]): " + brightness); return; } From eb7c7a54986ccdaef367acbcfc28c7dfc1a0f418 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Feb 2020 00:32:26 +0200 Subject: [PATCH 122/153] Fix moodlight saving false-positive scripter detection --- .../incoming/rooms/items/MoodLightSaveSettingsEvent.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index 7d3d39f2..04934da6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -14,6 +14,7 @@ import java.util.List; public class MoodLightSaveSettingsEvent extends MessageHandler { public static List MOODLIGHT_AVAILABLE_COLORS = Arrays.asList("#74F5F5,#0053F7,#E759DE,#EA4532,#F2F851,#82F349,#000000".split(",")); + public static int MIN_BRIGHTNESS = (int) Math.floor(0.3 * 0xFF); @Override public void handle() throws Exception { @@ -33,7 +34,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { return; } - if (brightness > 0xFF || brightness < (0.3 * 0xFF)) { + if (brightness > 0xFF || brightness < MIN_BRIGHTNESS) { ScripterManager.scripterDetected(this.client, "User tried to set a moodlight's brightness to out-of-bounds ([76, 255]): " + brightness); return; } From 0d9afb933eae911fd7fcc310cc92f153a0005758 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Feb 2020 00:33:14 +0200 Subject: [PATCH 123/153] Add extra error logging if there are no YT playlists for item --- .../items/youtube/YoutubeRequestPlaylists.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java index 469861d0..6c4b804b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java @@ -1,11 +1,15 @@ package com.eu.habbo.messages.incoming.rooms.items.youtube; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.YoutubeManager; import com.eu.habbo.habbohotel.items.interactions.InteractionYoutubeTV; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayListComposer; +import java.util.ArrayList; + public class YoutubeRequestPlaylists extends MessageHandler { @Override public void handle() throws Exception { @@ -17,7 +21,15 @@ public class YoutubeRequestPlaylists extends MessageHandler { if (item instanceof InteractionYoutubeTV) { InteractionYoutubeTV tv = (InteractionYoutubeTV) item; - this.client.sendResponse(new YoutubeDisplayListComposer(itemId, Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()), tv.currentPlaylist)); + ArrayList playlists = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()); + + if (playlists == null) { + Emulator.getLogging().logErrorLine("No YouTube playlists set for base item #" + item.getBaseItem().getId()); + this.client.sendResponse(new ConnectionErrorComposer(1000)); + return; + } + + this.client.sendResponse(new YoutubeDisplayListComposer(itemId, playlists, tv.currentPlaylist)); } } } From 47825978cbb68cc43d2be3f49f6e6a0f4e54991b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Feb 2020 00:35:39 +0200 Subject: [PATCH 124/153] Fix StringIndexOutOfBoundsException in floorplan saving --- .../incoming/floorplaneditor/FloorPlanEditorSaveEvent.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index ac8902e4..113dd0e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -58,6 +58,11 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { if (mapRows.length > 64) errors.add("${notification.floorplan_editor.error.message.too_large_height}"); else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > 64 || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}"); + + if (errors.length() > 0) { + this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString())); + return; + } } int doorX = this.packet.readInt(); From 1c5e1804479c86a3412e7d4eafd4414d99763b23 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Feb 2020 00:39:07 +0200 Subject: [PATCH 125/153] Ensure monsterplants don't get rarity 0 --- .../items/interactions/pets/InteractionMonsterPlantSeed.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java index 96e79004..8bbe249c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java @@ -33,7 +33,7 @@ public class InteractionMonsterPlantSeed extends HabboItem { public static int randomRarityLevel() { int number = Emulator.getRandom().nextInt(66); int count = 0; - for (int i = 1; i <= 11; i++) { + for (int i = 1; i < 11; i++) { count += 11 - i; if (number <= count) { return i; From 800b008b55699170b63627e2cd676d759cde1e4d Mon Sep 17 00:00:00 2001 From: skeletor Date: Sat, 22 Feb 2020 17:40:12 -0500 Subject: [PATCH 126/153] Don't activate match furni effect if settings are not configured --- .../interactions/wired/effects/WiredEffectMatchFurni.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index dc90e2b7..b318a033 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -44,6 +44,9 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { THashSet tilesToUpdate = new THashSet<>(this.settings.size()); //this.refresh(); + if(this.settings.isEmpty()) + return false; + for (WiredMatchFurniSetting setting : this.settings) { HabboItem item = room.getHabboItem(setting.itemId); if (item != null) { @@ -126,7 +129,6 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { if (slideAnimation && t != null) { room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose()); - room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); } else { room.updateItem(item); } From 6a992dbda9cc24510152891d982e3ebb1be00db4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Feb 2020 00:41:13 +0200 Subject: [PATCH 127/153] Fix NPE in GameTeam --- src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java index 5a5ba98b..aad945b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java @@ -72,7 +72,7 @@ public class GameTeam { for (GamePlayer player : this.members) { if (player == null || player.getHabbo() == null) continue; - player.getHabbo().getHabboInfo().getGamePlayer().reset(); + if (player.getHabbo().getHabboInfo().getGamePlayer() != null) player.getHabbo().getHabboInfo().getGamePlayer().reset(); player.getHabbo().getHabboInfo().setCurrentGame(null); player.getHabbo().getHabboInfo().setGamePlayer(null); } From 285fe970758dbde95c151971b12216a80c62f61f Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 23 Feb 2020 00:42:29 +0200 Subject: [PATCH 128/153] Fix NPE in freeze tile --- .../items/interactions/games/freeze/InteractionFreezeTile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java index f8971b4f..5b98b827 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java @@ -76,7 +76,7 @@ public class InteractionFreezeTile extends HabboItem { @Override public boolean canStackAt(Room room, List>> itemsAtLocation) { for (Pair> set : itemsAtLocation) { - if (!set.getValue().isEmpty()) return false; + if (set.getValue() != null && !set.getValue().isEmpty()) return false; } return super.canStackAt(room, itemsAtLocation); From 36ce06b22671752f9bd167784743d0493925db58 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 19:38:02 +0200 Subject: [PATCH 129/153] Fix pathfinder --- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 70 +++++++++++-------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 3f99af34..03a4a382 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -265,41 +265,48 @@ public class RoomLayout { public final Deque findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) { if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) return new LinkedList<>(); + LinkedList openList = new LinkedList<>(); List closedList = new LinkedList<>(); - RoomTile current; openList.add(oldTile.copy()); - while (!openList.isEmpty()) { - current = this.lowestFInOpen(openList); - if ((current.x == newTile.x) && (current.y == newTile.y)) { - return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); + while (!openList.isEmpty()) { + RoomTile current = this.lowestFInOpen(openList); + if (current.x == newTile.x && current.y == newTile.y) { + return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); } + closedList.add(current); openList.remove(current); - List adjacentNodes = this.getAdjacent(openList, current, newTile); + + List adjacentNodes = this.getAdjacent(openList, current, newTile, roomUnit); for (RoomTile currentAdj : adjacentNodes) { if (closedList.contains(currentAdj)) continue; - if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) { - currentAdj.setPrevious(current); - currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); - currentAdj.setgCosts(current); - openList.add(currentAdj); - continue; - } - if ((currentAdj.state == RoomTileState.BLOCKED) || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) { + + if (roomUnit.canOverrideTile(currentAdj) || (currentAdj.state != RoomTileState.BLOCKED && currentAdj.x == doorX && currentAdj.y == doorY)) { + currentAdj.setPrevious(current); + currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); + currentAdj.setgCosts(current); + openList.add(currentAdj); + continue; + } + + if (currentAdj.state == RoomTileState.BLOCKED || ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; } + double height = currentAdj.getStackHeight() - current.getStackHeight(); if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; + if (currentAdj.hasUnits() && ((!isWalktroughRetry && !this.room.isAllowWalkthrough()) || currentAdj.equals(goalLocation))) { closedList.add(currentAdj); openList.remove(currentAdj); continue; } + if (!openList.contains(currentAdj)) { currentAdj.setPrevious(current); currentAdj.sethCosts(this.findTile(openList, newTile.x, newTile.y)); @@ -311,9 +318,8 @@ public class RoomLayout { } } } - // System.out.println("Invalid Path."); - if (!this.room.isAllowWalkthrough()) { + if (!this.room.isAllowWalkthrough() && !isWalktroughRetry) { return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); } @@ -335,7 +341,7 @@ public class RoomLayout { return null; } - private Deque calcPath(RoomTile start, RoomTile goal) { + public Deque calcPath(RoomTile start, RoomTile goal) { LinkedList path = new LinkedList<>(); if (start == null) return path; @@ -364,13 +370,13 @@ public class RoomLayout { return cheapest; } - private List getAdjacent(List openList, RoomTile node, RoomTile nextTile) { + private List getAdjacent(List openList, RoomTile node, RoomTile nextTile, RoomUnit unit) { short x = node.x; short y = node.y; List adj = new LinkedList<>(); if (x > 0) { RoomTile temp = this.findTile(openList, (short) (x - 1), y); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) @@ -380,7 +386,7 @@ public class RoomLayout { } if (x < this.mapSizeX) { RoomTile temp = this.findTile(openList, (short) (x + 1), y); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) @@ -390,7 +396,7 @@ public class RoomLayout { } if (y > 0) { RoomTile temp = this.findTile(openList, x, (short) (y - 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) @@ -400,7 +406,7 @@ public class RoomLayout { } if (y < this.mapSizeY) { RoomTile temp = this.findTile(openList, x, (short) (y + 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(false); if (!adj.contains(temp)) @@ -414,7 +420,7 @@ public class RoomLayout { RoomTile offY = this.findTile(openList, x, (short) (y + 1)); if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y + 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) @@ -428,7 +434,7 @@ public class RoomLayout { RoomTile offY = this.findTile(openList, x, (short) (y - 1)); if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y - 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) @@ -442,7 +448,7 @@ public class RoomLayout { RoomTile offY = this.findTile(openList, x, (short) (y + 1)); if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y + 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) @@ -456,7 +462,7 @@ public class RoomLayout { RoomTile offY = this.findTile(openList, x, (short) (y - 1)); if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) { RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y - 1)); - if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID) { + if (this.canWalkOn(temp, unit)) { if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) { temp.isDiagonally(true); if (!adj.contains(temp)) @@ -469,6 +475,10 @@ public class RoomLayout { return adj; } + private boolean canWalkOn(RoomTile tile, RoomUnit unit) { + return tile != null && (unit.canOverrideTile(tile) || (tile.state != RoomTileState.BLOCKED && tile.state != RoomTileState.INVALID)); + } + public void moveDiagonally(boolean value) { this.CANMOVEDIAGONALY = value; } @@ -545,10 +555,14 @@ public class RoomLayout { } public List getTilesAround(RoomTile tile, int directionOffset) { - List tiles = new ArrayList<>(8); + return getTilesAround(tile, directionOffset, true); + } + + public List getTilesAround(RoomTile tile, int directionOffset, boolean diagonal) { + List tiles = new ArrayList<>(diagonal ? 8 : 4); if (tile != null) { - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 8; i += (diagonal ? 1 : 2)) { RoomTile t = this.getTileInFront(tile, (i + directionOffset) % 8); if (t != null) { tiles.add(t); From 518e12c6ad91e3ffee8c9e736c24fc1e1a9b525c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 19:48:17 +0200 Subject: [PATCH 130/153] Run YTTV manager initialization in a separate thread --- .../habbohotel/items/YoutubeManager.java | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java index 631f15d5..4e9ce06d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -77,42 +77,44 @@ public class YoutubeManager { long millis = System.currentTimeMillis(); - ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); + Emulator.getThreading().run(() -> { + ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); - Emulator.getLogging().logStart("YouTube Manager -> Loading..."); + Emulator.getLogging().logStart("YouTube Manager -> Loading..."); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) { - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - final int itemId = set.getInt("item_id"); - final String playlistId = set.getString("playlist_id"); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + final int itemId = set.getInt("item_id"); + final String playlistId = set.getString("playlist_id"); - youtubeDataLoaderPool.submit(() -> { - ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); + youtubeDataLoaderPool.submit(() -> { + ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); - YoutubePlaylist playlist = this.getPlaylistDataById(playlistId); - if (playlist != null) { - playlists.add(playlist); - } else { - Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId); - } + YoutubePlaylist playlist = this.getPlaylistDataById(playlistId); + if (playlist != null) { + playlists.add(playlist); + } else { + Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId); + } - this.playlists.put(itemId, playlists); - }); + this.playlists.put(itemId, playlists); + }); + } } + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); } - } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - } - youtubeDataLoaderPool.shutdown(); - try { - youtubeDataLoaderPool.awaitTermination(60, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } + youtubeDataLoaderPool.shutdown(); + try { + youtubeDataLoaderPool.awaitTermination(60, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } - Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + }); } public YoutubePlaylist getPlaylistDataById(String playlistId) { From 70d20ff2dd861cdfbe46c891a7a807ec7d1f6540 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 20:24:37 +0200 Subject: [PATCH 131/153] Remove onWalk and onWalkOff object data --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 7eb7278b..7b01af64 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -291,7 +291,7 @@ public class RoomUnit { if (item != null) { if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) { if (item.canWalkOn(this, room, null)) { - item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next}); + item.onWalkOn(this, room, null); } else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) { this.setRotation(oldRotation); this.tilesWalked--; @@ -306,7 +306,7 @@ public class RoomUnit { return false; } } else { - item.onWalk(this, room, new Object[]{this.getCurrentLocation(), next}); + item.onWalk(this, room, null); } zHeight += item.getZ(); From 4c77c76bdca469202911e5d1b378f0571db56e82 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 21:06:36 +0200 Subject: [PATCH 132/153] Add message-specific ratelimiting --- .../habbohotel/gameclients/GameClient.java | 3 ++- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 4 ++-- .../com/eu/habbo/messages/PacketManager.java | 16 +++++++++++-- .../messages/incoming/MessageHandler.java | 4 ++++ .../rooms/users/RoomUserWalkEvent.java | 23 +++++++++++++++++++ 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java index 376f910c..6b7ff3f5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -5,6 +5,7 @@ import com.eu.habbo.core.Logging; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.MessageComposer; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -17,12 +18,12 @@ import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; public class GameClient { - public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); private final Channel channel; public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); private Habbo habbo; private String machineId = ""; + public final ConcurrentHashMap, Long> messageTimestamps = new ConcurrentHashMap<>(); public GameClient(Channel channel) { this.channel = channel; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 7b01af64..7eb7278b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -291,7 +291,7 @@ public class RoomUnit { if (item != null) { if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) { if (item.canWalkOn(this, room, null)) { - item.onWalkOn(this, room, null); + item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next}); } else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) { this.setRotation(oldRotation); this.tilesWalked--; @@ -306,7 +306,7 @@ public class RoomUnit { return false; } } else { - item.onWalk(this, room, null); + item.onWalk(this, room, new Object[]{this.getCurrentLocation(), next}); } zHeight += item.getZ(); diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 7ebfe092..8acc8689 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -171,6 +171,20 @@ public class PacketManager { return; } + final MessageHandler handler = handlerClass.newInstance(); + + if (handler.getRatelimit() > 0) { + if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) { + if (PacketManager.DEBUG_SHOW_PACKETS) { + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "][" + Logging.ANSI_RED + "RATELIMITED" + Logging.ANSI_RESET + "] => " + packet.getMessageBody()); + } + + return; + } else { + client.messageTimestamps.put(handlerClass, System.currentTimeMillis()); + } + } + if (PacketManager.DEBUG_SHOW_PACKETS) Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); @@ -178,8 +192,6 @@ public class PacketManager { System.out.println(("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + client.getHabbo().getHabboInfo().getUsername() + "][" + packet.getMessageId() + "] => " + packet.getMessageBody())); } - final MessageHandler handler = handlerClass.newInstance(); - handler.client = client; handler.packet = packet; diff --git a/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java b/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java index 98baf3b6..38920afe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java +++ b/src/main/java/com/eu/habbo/messages/incoming/MessageHandler.java @@ -9,4 +9,8 @@ public abstract class MessageHandler { public boolean isCancelled = false; public abstract void handle() throws Exception; + + public int getRatelimit() { + return 0; + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index c14d6f66..22c0d5cc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -11,8 +11,14 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; +import gnu.trove.set.hash.THashSet; public class RoomUserWalkEvent extends MessageHandler { + @Override + public int getRatelimit() { + return 500; + } + @Override public void handle() throws Exception { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { @@ -115,6 +121,23 @@ public class RoomUserWalkEvent extends MessageHandler { } } + THashSet items = room.getItemsAt(tile); + + if (items.size() > 0) { + for (HabboItem item : items) { + RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile); + + if (overriddenTile == null) { + return; // null cancels the entire event + } + + if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) { + tile = overriddenTile; + break; + } + } + } + // This is where we set the end location and begin finding a path if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get(); From 166d8e8f4076e3c1021b30a481b3f9c81dc6a30c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 22:33:08 +0200 Subject: [PATCH 133/153] Fix NullPointerException in RoomManager.openRoom --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index b0512576..8ea0d9a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -596,7 +596,7 @@ public class RoomManager { habbo.getRoomUnit().clearStatus(); if (habbo.getRoomUnit().getCurrentLocation() == null) { habbo.getRoomUnit().setLocation(doorLocation != null ? doorLocation : room.getLayout().getDoorTile()); - habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); + if (habbo.getRoomUnit().getCurrentLocation() != null) habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); if (doorLocation == null) { habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]); From ece55786d8547983ba0130ad41102770e0ef2407 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 22:35:03 +0200 Subject: [PATCH 134/153] Fix NPE caused by Room.removeHabbo --- .../com/eu/habbo/habbohotel/rooms/Room.java | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 326fb66f..5fb0b622 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -570,6 +570,9 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem lowestChair = this.getLowestChair(tile); THashSet items = this.getItemsAt(tile); if (items == null) return RoomTileState.INVALID; + + if (items.stream().anyMatch(i -> i.getBaseItem().allowLay())) return RoomTileState.LAY; + for (HabboItem item : items) { if (exclude != null && item == exclude) continue; @@ -853,10 +856,11 @@ public class Room implements Comparable, ISerialize, Runnable { return; if (this.loaded) { - if (!this.traxManager.disposed()) { - this.traxManager.dispose(); - } try { + if (!this.traxManager.disposed()) { + this.traxManager.dispose(); + } + this.roomCycleTask.cancel(false); this.scheduledTasks.clear(); this.scheduledComposers.clear(); @@ -936,12 +940,16 @@ public class Room implements Comparable, ISerialize, Runnable { } } - this.wordQuiz = ""; - this.yesVotes = 0; - this.noVotes = 0; - this.updateDatabaseUserCount(); - this.preLoaded = true; - this.layout = null; + try { + this.wordQuiz = ""; + this.yesVotes = 0; + this.noVotes = 0; + this.updateDatabaseUserCount(); + this.preLoaded = true; + this.layout = null; + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } } Emulator.getPluginManager().fireEvent(new RoomUnloadedEvent(this)); @@ -2598,13 +2606,15 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose()); } - HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); + if (habbo.getRoomUnit().getCurrentLocation() != null) { + HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); - if (item != null) { - try { - item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); - } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + if (item != null) { + try { + item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); + } catch (Exception e) { + Emulator.getLogging().logErrorLine(e); + } } } From b8d52b08d38c83a97899fe913f624640f084e2de Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 22:39:31 +0200 Subject: [PATCH 135/153] Do not activate wired conditions unless double-clicked --- .../com/eu/habbo/habbohotel/wired/WiredHandler.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 cc0c9ac7..3e48eb85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -139,12 +139,11 @@ public class WiredHandler { } for (InteractionWiredCondition condition : conditions) { - if ((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) || - (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) { - condition.activateBox(room); - } else { - if (!Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled()) - return false; + if (!((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) || + (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) && + !Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled()) { + + return false; } } } From 09114ba9774ae4ab40b1df053ad1de4d5cf749be Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 22:53:06 +0200 Subject: [PATCH 136/153] Allow placing stack helpers on users, bots and pets --- .../com/eu/habbo/habbohotel/rooms/Room.java | 24 +++++++++---------- .../habbo/habbohotel/wired/WiredHandler.java | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 5fb0b622..11f81d96 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4366,6 +4366,8 @@ public class Room implements Comparable, ISerialize, Runnable { if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; + if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE; + THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); for (RoomTile t : occupiedTiles) { @@ -4374,24 +4376,20 @@ public class Room implements Comparable, ISerialize, Runnable { if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; } - boolean magicTile = item instanceof InteractionStackHelper; + List>> tileFurniList = new ArrayList<>(); + for (RoomTile t : occupiedTiles) { + tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - if (!magicTile) { - List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - - HabboItem topItem = this.getTopItemAt(t.x, t.y, item); - if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { - return FurnitureMovementError.CANT_STACK; - } - } - - if (!item.canStackAt(this, tileFurniList)) { + HabboItem topItem = this.getTopItemAt(t.x, t.y, item); + if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { return FurnitureMovementError.CANT_STACK; } } + if (!item.canStackAt(this, tileFurniList)) { + return FurnitureMovementError.CANT_STACK; + } + return FurnitureMovementError.NONE; } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 3e48eb85..ce4b7361 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -142,7 +142,7 @@ public class WiredHandler { if (!((condition.operator() == WiredConditionOperator.OR && matchedConditions.contains(condition.getType())) || (condition.operator() == WiredConditionOperator.AND && condition.execute(roomUnit, room, stuff))) && !Emulator.getPluginManager().fireEvent(new WiredConditionFailedEvent(room, roomUnit, trigger, condition)).isCancelled()) { - + return false; } } From 8c9faa56e671746eb9a2bbbc070185ca6068f1e4 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 22:55:09 +0200 Subject: [PATCH 137/153] Fix NPE in TraxManager.fromItemId --- src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 04b13d82..334ddc17 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -261,7 +261,7 @@ public class TraxManager implements Disposable { public InteractionMusicDisc fromItemId(int itemId) { for (InteractionMusicDisc musicDisc : this.songs) { - if (musicDisc.getId() == itemId) { + if (musicDisc != null && musicDisc.getId() == itemId) { return musicDisc; } } From 706577f220a1b06fb636369c04560cdf67cd0fa8 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 23:16:36 +0200 Subject: [PATCH 138/153] Fix vending machines without sides --- .../InteractionVendingMachine.java | 18 ++++++------------ .../eu/habbo/habbohotel/rooms/RoomUnit.java | 2 +- .../runnables/RoomUnitWalkToLocation.java | 13 +++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java index 4ddc40bf..55b96e98 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java @@ -83,11 +83,10 @@ public class InteractionVendingMachine extends HabboItem { } } - List onSuccess = new ArrayList<>(); - List onFail = new ArrayList<>(); - RoomTile finalTile = tile; - onSuccess.add(() -> { + client.getHabbo().getRoomUnit().setGoalLocation(tile); + + Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, () -> { this.setExtradata("1"); room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose()); @@ -98,7 +97,7 @@ public class InteractionVendingMachine extends HabboItem { } Emulator.getThreading().run(() -> { - Runnable procedure = () -> { + client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> { if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) { this.rotateToMachine(client.getHabbo().getRoomUnit()); room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose()); @@ -117,14 +116,9 @@ public class InteractionVendingMachine extends HabboItem { } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } - }; - - client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(procedure, 300)); + }, 300)); }, 250); - }); - - client.getHabbo().getRoomUnit().setGoalLocation(tile); - Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail)); + }, null)); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 7eb7278b..e0aa77b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -781,7 +781,7 @@ public class RoomUnit { return this.getClosestTile( rotations.stream() .map(rotation -> room.getLayout().getTileInFront(baseTile, rotation)) - .filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y)) + .filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y))) .collect(Collectors.toList()) ); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java index 21356e91..7a648ff0 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import java.util.ArrayList; import java.util.List; public class RoomUnitWalkToLocation implements Runnable { @@ -14,6 +15,18 @@ public class RoomUnitWalkToLocation implements Runnable { private List targetReached; private List failedReached; + public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, Runnable targetReached, Runnable failedReached) { + this.walker = walker; + this.goalTile = goalTile; + this.room = room; + + this.targetReached = new ArrayList<>(); + if (targetReached != null) this.targetReached.add(targetReached); + + this.failedReached = new ArrayList<>(); + if (failedReached != null) this.targetReached.add(failedReached); + } + public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, List targetReached, List failedReached) { this.walker = walker; this.goalTile = goalTile; From ae51fa88a5c3344d62d386dbed0e55a0d45574ab Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 23:29:23 +0200 Subject: [PATCH 139/153] Fix stackable furni not working with WIRED Effect: Match Furni Direction --- .../wired/effects/WiredEffectChangeFurniDirection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index dbd0907d..3a9b1f3c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -62,7 +62,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue()); int count = 1; - while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID) && count < 8) { + while ((targetTile == null || !targetTile.getAllowStack() || targetTile.state == RoomTileState.INVALID || targetTile.state == RoomTileState.BLOCKED) && count < 8) { entry.setValue(this.nextRotation(entry.getValue())); targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY()), entry.getValue().getValue()); count++; From 8adb814f66336fd227f4913b8316b283850117a8 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 23:52:40 +0200 Subject: [PATCH 140/153] Fix bot placing on chairs and beds --- .../java/com/eu/habbo/habbohotel/bots/BotManager.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 97484248..04e92001 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -113,15 +113,19 @@ public class BotManager { return; } - if (!room.hasHabbosAt(location.x, location.y) && !location.isWalkable() && location.state != RoomTileState.SIT) + if (!room.hasHabbosAt(location.x, location.y) && !location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY) return; RoomUnit roomUnit = new RoomUnit(); roomUnit.setRotation(RoomUserRotation.SOUTH); roomUnit.setLocation(location); HabboItem topItem = room.getTopItemAt(location.x, location.y); - roomUnit.setZ(roomUnit.getCurrentLocation().getStackHeight()); - roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight()); + + double topItemHeight = 0; + if (topItem != null) topItemHeight = Item.getCurrentHeight(topItem); + roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight() - topItemHeight); + + roomUnit.setPathFinderRoom(room); roomUnit.setRoomUnitType(RoomUnitType.BOT); roomUnit.setCanWalk(room.isAllowBotsWalk()); @@ -136,7 +140,6 @@ public class BotManager { bot.onPlace(habbo, room); if (topItem != null) { - roomUnit.setZ(topItem.getBaseItem().allowSit() ? topItem.getZ() : topItem.getZ() + Item.getCurrentHeight(topItem)); try { topItem.onWalkOn(bot.getRoomUnit(), room, null); } catch (Exception e) { From a8f3829216b25725c32b2a49976ba30a78f02b72 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Thu, 27 Feb 2020 23:59:27 +0200 Subject: [PATCH 141/153] Fix placing bots --- src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 04e92001..3afd12e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -113,7 +113,7 @@ public class BotManager { return; } - if (!room.hasHabbosAt(location.x, location.y) && !location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY) + if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY)) return; RoomUnit roomUnit = new RoomUnit(); From 8d6cd27b8562e19d6a51b9d72389206953d01205 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 4 Mar 2020 18:45:33 +0200 Subject: [PATCH 142/153] Fix rotating furniture with a stack helper --- .../com/eu/habbo/habbohotel/rooms/Room.java | 47 ++++++++++++------- .../events/users/HabboAddedToRoomEvent.java | 2 +- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 11f81d96..1815fe56 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4471,26 +4471,31 @@ public class Room implements Comparable, ISerialize, Runnable { boolean magicTile = item instanceof InteractionStackHelper; + Optional stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny(); + //Check if can be placed at new position THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - if (topItem != item) { - for (RoomTile t : occupiedTiles) { - HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); - if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) - return FurnitureMovementError.CANT_STACK; - if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; - if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; - if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + + if (!stackHelper.isPresent()) { + if (topItem != item) { + for (RoomTile t : occupiedTiles) { + HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); + if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) + return FurnitureMovementError.CANT_STACK; + if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; + if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; + if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS; + } } - } - List>> tileFurniList = new ArrayList<>(); - for (RoomTile t : occupiedTiles) { - tileFurniList.add(Pair.create(t, this.getItemsAt(t))); - } + List>> tileFurniList = new ArrayList<>(); + for (RoomTile t : occupiedTiles) { + tileFurniList.add(Pair.create(t, this.getItemsAt(t))); + } - if (!magicTile && !item.canStackAt(this, tileFurniList)) { - return FurnitureMovementError.CANT_STACK; + if (!magicTile && !item.canStackAt(this, tileFurniList)) { + return FurnitureMovementError.CANT_STACK; + } } THashSet oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); @@ -4511,8 +4516,16 @@ public class Room implements Comparable, ISerialize, Runnable { } //Place at new position - double height = this.getStackHeight(tile.x, tile.y, false, item); - if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) height = item.getZ(); + double height; + + if (stackHelper.isPresent()) { + height = stackHelper.get().getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(stackHelper.get().getExtradata()) / 100); + } else if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) { + height = item.getZ(); + } else { + height = this.getStackHeight(tile.x, tile.y, false, item); + } + if(height > 40d) return FurnitureMovementError.CANT_STACK; item.setX(tile.x); diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java index d31f4a6c..2e5ab84b 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java @@ -8,7 +8,7 @@ import java.util.Collection; public class HabboAddedToRoomEvent extends UserEvent { public final Room room; - public final Collection habbosToSendEnter; + public Collection habbosToSendEnter; public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter) { From ef5e3a7c321b856efaaab81616ff14959a444a9d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 4 Mar 2020 18:57:04 +0200 Subject: [PATCH 143/153] Fix trophies not allowing walking on them --- .../items/interactions/InteractionTrophy.java | 44 +------------------ .../com/eu/habbo/habbohotel/rooms/Room.java | 2 +- 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java index 36d978e8..791109a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java @@ -1,16 +1,11 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.ServerMessage; import java.sql.ResultSet; import java.sql.SQLException; -public class InteractionTrophy extends HabboItem { +public class InteractionTrophy extends InteractionDefault { public InteractionTrophy(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -18,41 +13,4 @@ public class InteractionTrophy extends HabboItem { public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); } - - @Override - public void serializeExtradata(ServerMessage serverMessage) { - serverMessage.appendInt((this.isLimited() ? 256 : 0)); - serverMessage.appendString(this.getExtradata()); - super.serializeExtradata(serverMessage); - } - - @Override - public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return true; - } - - @Override - public boolean isWalkable() { - return false; - } - - @Override - public void onClick(GameClient client, Room room, Object[] objects) throws Exception { - super.onClick(client, room, objects); - } - - @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } - - @Override - public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } - - @Override - public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - - } } 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 1815fe56..17d2e66d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4475,7 +4475,7 @@ public class Room implements Comparable, ISerialize, Runnable { //Check if can be placed at new position THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); - + if (!stackHelper.isPresent()) { if (topItem != item) { for (RoomTile t : occupiedTiles) { From 47e9d1a64b09ad7b458279aead66efe24ee0fff1 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Wed, 4 Mar 2020 20:28:12 +0200 Subject: [PATCH 144/153] Modify HabboAddedToRoomEvent --- .../java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 8 +++++--- .../habbo/plugin/events/users/HabboAddedToRoomEvent.java | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 8ea0d9a5..2faa824c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -713,21 +713,23 @@ public class RoomManager { if (!room.getCurrentHabbos().isEmpty()) { Collection habbosToSendEnter = room.getCurrentHabbos().values(); + Collection visibleHabbos = room.getHabbos(); if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { - HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter)); + HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter, visibleHabbos)); habbosToSendEnter = event.habbosToSendEnter; + visibleHabbos = event.visibleHabbos; } for (Habbo habboToSendEnter : habbosToSendEnter) { GameClient client = habboToSendEnter.getClient(); if (client != null) { client.sendResponse(new RoomUsersComposer(habbo).compose()); - habboToSendEnter.getClient().sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); + client.sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); } } - for (Habbo h : room.getHabbos()) { + for (Habbo h : visibleHabbos) { if (!h.getRoomUnit().isInvisible()) { habbos.add(h); } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java index 2e5ab84b..8753b8bf 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java @@ -9,12 +9,13 @@ public class HabboAddedToRoomEvent extends UserEvent { public final Room room; public Collection habbosToSendEnter; + public Collection visibleHabbos; - - public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter) { + public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter, Collection visibleHabbos) { super(habbo); this.room = room; this.habbosToSendEnter = habbosToSendEnter; + this.visibleHabbos = visibleHabbos; } } From 7ab78798b695c90164ec362c88ab117563bd4de7 Mon Sep 17 00:00:00 2001 From: skeletor Date: Fri, 13 Mar 2020 10:47:20 -0400 Subject: [PATCH 145/153] fixed nullpointer exception in RoomUnit.java --- src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index e0aa77b9..a8c0e831 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -761,6 +761,8 @@ public class RoomUnit { } public RoomTile getClosestAdjacentTile(short x, short y, boolean diagonal) { + if(room == null) return null; + RoomTile baseTile = room.getLayout().getTile(x, y); if (baseTile == null) return null; From e6c53394397601ffd5bb6a4ae6e21f3cb7215c23 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 15:01:26 +0000 Subject: [PATCH 146/153] Added text to emulator_texts. fixes #480 --- sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql | 7 +++++++ sqlupdates/2_3_0-RC-3 TO 2_3_0.sql | 1 + .../com/eu/habbo/habbohotel/commands/CommandsCommand.java | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql create mode 100644 sqlupdates/2_3_0-RC-3 TO 2_3_0.sql diff --git a/sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql b/sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql new file mode 100644 index 00000000..d1a5d906 --- /dev/null +++ b/sqlupdates/2_3_0-RC-2_TO_2_3_0-RC-3.sql @@ -0,0 +1,7 @@ +ALTER TABLE `users_pets` +ADD COLUMN `saddle_item_id` int(11) NULL; + +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.bot.placement.messages', 'Yo!;Hello I\'m a real party animal!;Hello!'); + +UPDATE `items_base` SET `customparams` = '1,true' WHERE `item_name` = 'wf_blob'; +UPDATE `items_base` SET `customparams` = '5,false' WHERE `item_name` = 'wf_blob2'; diff --git a/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql b/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql new file mode 100644 index 00000000..d9e96ffd --- /dev/null +++ b/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql @@ -0,0 +1 @@ +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.generic.cmd_commands.text', 'Your Commands'); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java index 026a1d53..358f4266 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsCommand.java @@ -12,7 +12,7 @@ public class CommandsCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - StringBuilder message = new StringBuilder("Your Commands"); + StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_commands.text")); List commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId()); message.append("(").append(commands.size()).append("):\r\n"); From 6111ce6be2a82c188fd7a1edab69c1b623b15af6 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 15:41:51 +0000 Subject: [PATCH 147/153] Fixed Teleports crashing. Credits to ArpyAge for helping. --- .../habbohotel/items/interactions/InteractionTeleport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8c20fa5b..69d7fe3a 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 @@ -205,7 +205,7 @@ public class InteractionTeleport extends HabboItem { if (habbo.getHabboInfo().getRiding() != null) return false; - return this.roomUnitID == -1 || this.roomUnitID == unit.getId(); + return true; } public void startTeleport(Room room, Habbo habbo) { From 0dc6ebda100f273e698d99f51dbf5ef403b95773 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 15:45:06 +0000 Subject: [PATCH 148/153] Fix npe #515 --- .../com/eu/habbo/threading/runnables/RoomUnitTeleport.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index f71173c3..70761558 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -35,6 +35,9 @@ public class RoomUnitTeleport implements Runnable { if (roomUnit == null || roomUnit.getRoom() == null) return; + if (room.getLayout() == null) + return; + RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y); HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); From 4c7ec55c60e7a2c0861d16bdbadb9123a552ba94 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 15:51:32 +0000 Subject: [PATCH 149/153] Cleanup for last commit. --- .../com/eu/habbo/threading/runnables/RoomUnitTeleport.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 70761558..18489aec 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -32,12 +32,9 @@ public class RoomUnitTeleport implements Runnable { @Override public void run() { - if (roomUnit == null || roomUnit.getRoom() == null) + if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null) return; - - if (room.getLayout() == null) - return; - + RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y); HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); From ce9aae174f973d064cff837a46c9d84e3560c8ec Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 16:11:06 +0000 Subject: [PATCH 150/153] Made plugins command no longer use a perm, always turned on. --- .../java/com/eu/habbo/habbohotel/commands/PluginsCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java index 75c978a2..bcaf30c0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java @@ -9,7 +9,7 @@ import java.util.Collections; public class PluginsCommand extends Command { public PluginsCommand() { - super("cmd_plugins", Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";")); + super(null, new String[]{"plugins"}); } @Override From b11923452f00206089ceff82800bfb1eb8f7b98b Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 17:00:48 +0000 Subject: [PATCH 151/153] Added stand command from habbo. --- sqlupdates/2_3_0-RC-3 TO 2_3_0.sql | 1 + .../habbohotel/commands/CommandHandler.java | 1 + .../habbohotel/commands/StandCommand.java | 18 ++++++++++++++++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 11 +++++++++++ .../eu/habbo/habbohotel/rooms/RoomUnit.java | 1 + 5 files changed, 32 insertions(+) create mode 100644 src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java diff --git a/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql b/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql index d9e96ffd..f403dc29 100644 --- a/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql +++ b/sqlupdates/2_3_0-RC-3 TO 2_3_0.sql @@ -1 +1,2 @@ INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.generic.cmd_commands.text', 'Your Commands'); +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.keys.cmd_stand', 'stand'); 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 d51eb126..dbf2fa6a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -245,6 +245,7 @@ public class CommandHandler { addCommand(new ShoutCommand()); addCommand(new ShutdownCommand()); addCommand(new SitCommand()); + addCommand(new StandCommand()); addCommand(new SitDownCommand()); addCommand(new StaffAlertCommand()); addCommand(new StaffOnlineCommand()); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java new file mode 100644 index 00000000..82bf092c --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/commands/StandCommand.java @@ -0,0 +1,18 @@ +package com.eu.habbo.habbohotel.commands; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.gameclients.GameClient; + +public class StandCommand extends Command { + public StandCommand() { + super(null, Emulator.getTexts().getValue("commands.keys.cmd_stand").split(";")); + } + + + @Override + public boolean handle(GameClient gameClient, String[] params) throws Exception { + if (gameClient.getHabbo().getHabboInfo().getRiding() == null) + gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeStand(gameClient.getHabbo()); + return true; + } +} 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 17d2e66d..a360a733 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3993,6 +3993,17 @@ public class Room implements Comparable, ISerialize, Runnable { this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); } + public void makeStand(Habbo habbo) { + if (habbo.getRoomUnit() == null) return; + HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); + if (item == null || !item.getBaseItem().allowSit()) { + habbo.getRoomUnit().cmdStand = true; + habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); + habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); + this.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); + } + } + public void giveEffect(Habbo habbo, int effectId, int duration) { if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { this.giveEffect(habbo.getRoomUnit(), effectId, duration); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index a8c0e831..6f72b1ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -38,6 +38,7 @@ public class RoomUnit { public boolean animateWalk = false; public boolean cmdTeleport = false; public boolean cmdSit = false; + public boolean cmdStand = false; public boolean cmdLay = false; public boolean sitUpdate = false; public boolean isTeleporting = false; From 490a1f4bde8462c8f6ddf68026ed728919d80885 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 17:03:30 +0000 Subject: [PATCH 152/153] Fixed stand command working on beds. --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index a360a733..c36b15b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3995,8 +3995,9 @@ public class Room implements Comparable, ISerialize, Runnable { public void makeStand(Habbo habbo) { if (habbo.getRoomUnit() == null) return; + HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY()); - if (item == null || !item.getBaseItem().allowSit()) { + if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { habbo.getRoomUnit().cmdStand = true; habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]); habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT); From b1bda73af32e2d10cb9b613836e1ca24648097e5 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Fri, 13 Mar 2020 19:07:34 +0000 Subject: [PATCH 153/153] Re-add configurable key for plugins. --- .../java/com/eu/habbo/habbohotel/commands/PluginsCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java index bcaf30c0..c468e0d1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/PluginsCommand.java @@ -9,7 +9,7 @@ import java.util.Collections; public class PluginsCommand extends Command { public PluginsCommand() { - super(null, new String[]{"plugins"}); + super(null, Emulator.getTexts().getValue("commands.keys.cmd_plugins").split(";")); } @Override