From 9e7abc9d4191854822f6fb090c98c13d90c6eea4 Mon Sep 17 00:00:00 2001 From: Beny Date: Wed, 14 Oct 2020 23:29:57 +0200 Subject: [PATCH 1/5] Bots can now be set a bubble. Closes #390 --- sqlupdates/2_4_0 to 2_5_0-RC-1.sql | 4 ++++ .../com/eu/habbo/habbohotel/bots/Bot.java | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sqlupdates/2_4_0 to 2_5_0-RC-1.sql b/sqlupdates/2_4_0 to 2_5_0-RC-1.sql index 5003f7fa..4fb7bc47 100644 --- a/sqlupdates/2_4_0 to 2_5_0-RC-1.sql +++ b/sqlupdates/2_4_0 to 2_5_0-RC-1.sql @@ -101,3 +101,7 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.m -- OPTIONAL HC MIGRATION -- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP(); + +ALTER TABLE `bots` +ADD COLUMN `bubble_id` int(3) NULL DEFAULT 31 AFTER `effect`; + 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 8cedc5ff..611d54cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -44,6 +44,7 @@ public class Bot implements Runnable { private int chatTimeOut; private int chatTimestamp; private short lastChatIndex; + private int bubble; private String type; @@ -73,6 +74,7 @@ public class Bot implements Runnable { this.chatLines = new ArrayList<>(); this.type = "generic_bot"; this.room = null; + this.bubble = RoomChatMessageBubbles.BOT_RENTABLE.getType(); } public Bot(ResultSet set) throws SQLException { @@ -94,6 +96,7 @@ public class Bot implements Runnable { this.roomUnit = null; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.needsUpdate = false; + this.bubble = set.getInt("bubble_id"); } public Bot(Bot bot) { @@ -110,6 +113,7 @@ public class Bot implements Runnable { this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D")); this.type = bot.getType(); this.effect = bot.getEffect(); + this.bubble = bot.getBubbleId(); this.needsUpdate = false; } @@ -133,7 +137,7 @@ public class Bot implements Runnable { @Override public void run() { if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ? WHERE id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.motto); statement.setString(3, this.figure); @@ -155,7 +159,8 @@ public class Bot implements Runnable { statement.setString(15, this.chatRandom ? "1" : "0"); statement.setInt(16, this.chatDelay); statement.setInt(17, this.effect); - statement.setInt(18, this.id); + statement.setInt(18, this.bubble); + statement.setInt(19, this.id); statement.execute(); this.needsUpdate = false; } catch (SQLException e) { @@ -208,7 +213,7 @@ public class Bot implements Runnable { return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose()); + this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); if (message.equals("o/") || message.equals("_o/")) { this.room.sendComposer(new RoomUserActionComposer(this.roomUnit, RoomUserAction.WAVE).compose()); @@ -223,7 +228,7 @@ public class Bot implements Runnable { return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose()); + this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose()); if (message.equals("o/") || message.equals("_o/")) { this.room.sendComposer(new RoomUserActionComposer(this.roomUnit, RoomUserAction.WAVE).compose()); @@ -238,7 +243,7 @@ public class Bot implements Runnable { return; this.chatTimestamp = Emulator.getIntUnixTimestamp(); - event.target.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE))); + event.target.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId())))); } } @@ -270,6 +275,10 @@ public class Bot implements Runnable { return this.name; } + public int getBubbleId() { + return bubble; + } + public void setName(String name) { this.name = name; this.needsUpdate = true; From afec2d2d0d25cb3619b5738384e676dd37a6e53c Mon Sep 17 00:00:00 2001 From: Beny Date: Wed, 14 Oct 2020 23:43:11 +0200 Subject: [PATCH 2/5] Fix unable to buy group with large days of HC left. Closes #845 --- .../eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java index 4913c027..574987fa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java @@ -27,7 +27,7 @@ public class RequestGuildBuyEvent extends MessageHandler { if(name.length() > 29 || description.length() > 254) return; - if (Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && this.client.getHabbo().getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) { + if (Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && !this.client.getHabbo().getHabboStats().hasActiveClub()) { this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.HC_REQUIRED)); return; } From b7b81e8af978a9794ff4ed1b74b77d4a7cd20eee Mon Sep 17 00:00:00 2001 From: Beny Date: Thu, 15 Oct 2020 00:27:53 +0200 Subject: [PATCH 3/5] Typo --- src/main/java/com/eu/habbo/habbohotel/bots/Bot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 611d54cf..674f5019 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -137,7 +137,7 @@ public class Bot implements Runnable { @Override public void run() { if (this.needsUpdate) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble = ? WHERE id = ?")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) { statement.setString(1, this.name); statement.setString(2, this.motto); statement.setString(3, this.figure); From 0d0f0d3373f7a081890e778265a4e5c76b82fe20 Mon Sep 17 00:00:00 2001 From: Beny Date: Thu, 15 Oct 2020 13:40:43 +0200 Subject: [PATCH 4/5] Figuredata parses correctly with whitespace now --- .../users/clothingvalidation/Figuredata.java | 88 +++++++++++-------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java index c8c67671..0f4aec7c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/Figuredata.java @@ -1,5 +1,6 @@ package com.eu.habbo.habbohotel.users.clothingvalidation; +import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -57,55 +58,64 @@ public class Figuredata { for(int i = 0; i < palettesList.getLength(); i++) { Node nNode = palettesList.item(i); - Element element = (Element)nNode; - int paletteId = Integer.parseInt(element.getAttribute("id")); - FiguredataPalette palette = new FiguredataPalette(paletteId); + if(nNode.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) nNode; + int paletteId = Integer.parseInt(element.getAttribute("id")); + FiguredataPalette palette = new FiguredataPalette(paletteId); - NodeList colorsList = nNode.getChildNodes(); - for(int ii = 0; ii < colorsList.getLength(); ii++) { - Element colorElement = (Element)colorsList.item(ii); - FiguredataPaletteColor color = new FiguredataPaletteColor( - Integer.parseInt(colorElement.getAttribute("id")), - Integer.parseInt(colorElement.getAttribute("index")), - !colorElement.getAttribute("club").equals("0"), - colorElement.getAttribute("selectable").equals("1"), - colorElement.getTextContent() - ); - palette.addColor(color); + NodeList colorsList = nNode.getChildNodes(); + for (int ii = 0; ii < colorsList.getLength(); ii++) { + if(colorsList.item(ii).getNodeType() == Node.ELEMENT_NODE) { + Element colorElement = (Element) colorsList.item(ii); + FiguredataPaletteColor color = new FiguredataPaletteColor( + Integer.parseInt(colorElement.getAttribute("id")), + Integer.parseInt(colorElement.getAttribute("index")), + !colorElement.getAttribute("club").equals("0"), + colorElement.getAttribute("selectable").equals("1"), + colorElement.getTextContent() + ); + palette.addColor(color); + } + } + + palettes.put(palette.id, palette); } - - palettes.put(palette.id, palette); } for(int i = 0; i < settypesList.getLength(); i++) { Node nNode = settypesList.item(i); - Element element = (Element)nNode; - String type = element.getAttribute("type"); - int paletteId = Integer.parseInt(element.getAttribute("paletteid")); - boolean mandM0 = element.getAttribute("mand_m_0").equals("1"); - boolean mandF0 = element.getAttribute("mand_f_0").equals("1"); - boolean mandM1 = element.getAttribute("mand_m_1").equals("1"); - boolean mandF1 = element.getAttribute("mand_f_1").equals("1"); + if(nNode.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) nNode; - FiguredataSettype settype = new FiguredataSettype(type, paletteId, mandM0, mandF0, mandM1, mandF1); + String type = element.getAttribute("type"); + int paletteId = Integer.parseInt(element.getAttribute("paletteid")); + boolean mandM0 = element.getAttribute("mand_m_0").equals("1"); + boolean mandF0 = element.getAttribute("mand_f_0").equals("1"); + boolean mandM1 = element.getAttribute("mand_m_1").equals("1"); + boolean mandF1 = element.getAttribute("mand_f_1").equals("1"); - NodeList setsList = nNode.getChildNodes(); - for(int ii = 0; ii < setsList.getLength(); ii++) { - Element setElement = (Element)setsList.item(ii); - FiguredataSettypeSet set = new FiguredataSettypeSet( - Integer.parseInt(setElement.getAttribute("id")), - setElement.getAttribute("gender"), - !setElement.getAttribute("club").equals("0"), - setElement.getAttribute("colorable").equals("1"), - setElement.getAttribute("selectable").equals("1"), - setElement.getAttribute("preselectable").equals("1"), - setElement.getAttribute("sellable").equals("1") - ); - settype.addSet(set); + FiguredataSettype settype = new FiguredataSettype(type, paletteId, mandM0, mandF0, mandM1, mandF1); + + NodeList setsList = nNode.getChildNodes(); + for (int ii = 0; ii < setsList.getLength(); ii++) { + if(setsList.item(ii).getNodeType() == Node.ELEMENT_NODE) { + Element setElement = (Element) setsList.item(ii); + FiguredataSettypeSet set = new FiguredataSettypeSet( + Integer.parseInt(setElement.getAttribute("id")), + setElement.getAttribute("gender"), + !setElement.getAttribute("club").equals("0"), + setElement.getAttribute("colorable").equals("1"), + setElement.getAttribute("selectable").equals("1"), + setElement.getAttribute("preselectable").equals("1"), + setElement.getAttribute("sellable").equals("1") + ); + settype.addSet(set); + } + } + + settypes.put(settype.type, settype); } - - settypes.put(settype.type, settype); } } From d1f18a2154d392b4014a26c23a916f3ba1e77201 Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 16 Oct 2020 03:22:12 -0400 Subject: [PATCH 5/5] Update 2_4_0 to 2_5_0-RC-1.sql --- sqlupdates/2_4_0 to 2_5_0-RC-1.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sqlupdates/2_4_0 to 2_5_0-RC-1.sql b/sqlupdates/2_4_0 to 2_5_0-RC-1.sql index 4fb7bc47..7cf2ee29 100644 --- a/sqlupdates/2_4_0 to 2_5_0-RC-1.sql +++ b/sqlupdates/2_4_0 to 2_5_0-RC-1.sql @@ -78,6 +78,8 @@ INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.points.hc_mo INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.credits.hc_modifier', '1'); INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.hc_modifier', '1'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('room.chat.mutearea.allow_whisper', '1'); + DELETE FROM `emulator_settings` WHERE `key` IN ('hotel.max.rooms.per.user', 'hotel.max.rooms.user', 'hotel.max.rooms.vip', 'max.friends', 'hotel.max.friends', 'max.friends.hc', 'hotel.max.friends.hc'); ALTER TABLE `users_settings` ADD COLUMN `max_friends` int(10) NULL DEFAULT 300 AFTER `has_gotten_default_saved_searches`;