From d97bc09c116d52797a465c24788d2fcd78e58c8e Mon Sep 17 00:00:00 2001 From: harmonic Date: Thu, 4 Jun 2020 14:23:19 +0100 Subject: [PATCH] Fixed Bot picking up, before if you had 15 in your inventory it wouldn't let you pick them up, but would allow you to buy more from the catalogue, i've set it to use the existing "hotel.bots.max.inventory" and it now checks on catalogue purchase and will alert you with a configurable message if you have too many, if you want it to act like habbo you can give users the unlimited bots perm. --- sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql | 5 ++++- src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java | 6 ++++-- .../messages/incoming/catalog/CatalogBuyItemEvent.java | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql index 2f406602..c775ff01 100644 --- a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql +++ b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql @@ -12,4 +12,7 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softki -- Rank ignoring INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('generic.error.ignore_higher_rank', 'You can\'t ignore this user.'); -INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.allow.ignore.staffs', '1'); \ No newline at end of file +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.allow.ignore.staffs', '1'); + +-- Bot Inventory Limiting +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('hotel.bot.max.amount.message', 'You can\'t buy or pickup anymore bots until you place some, the maximum amount of bots you are allowed is %amount%.'); 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 d948c332..f6449e4f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -163,6 +163,7 @@ public class BotManager { } public void pickUpBot(Bot bot, Habbo habbo) { + int botConfigSize = Emulator.getConfig().getInt("hotel.bots.max.inventory"); if (bot != null && habbo != null) { BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, habbo); Emulator.getPluginManager().fireEvent(pickedUpEvent); @@ -171,8 +172,9 @@ public class BotManager { return; if (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) { - if (!habbo.hasPermission("acc_unlimited_bots") && habbo.getInventory().getBotsComponent().getBots().size() >= 15) - return; + if (!habbo.hasPermission("acc_unlimited_bots") && habbo.getInventory().getBotsComponent().getBots().size() >= botConfigSize) { + habbo.alert(Emulator.getTexts().getValue("hotel.bot.max.amount.message").replace("%amount%", botConfigSize + "")); + } bot.onPickUp(habbo, habbo.getHabboInfo().getCurrentRoom()); habbo.getHabboInfo().getCurrentRoom().removeBot(bot); diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java index a20ea1b8..b154b49e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemEvent.java @@ -192,6 +192,13 @@ public class CatalogBuyItemEvent extends MessageHandler { else item = page.getCatalogItem(itemId); // temp patch, can a dev with better knowledge than me look into this asap pls. + if (page instanceof BotsLayout) { + int botConfigSize = Emulator.getConfig().getInt("hotel.bots.max.inventory"); + if (!this.client.getHabbo().hasPermission("acc_unlimited_bots") && this.client.getHabbo().getInventory().getBotsComponent().getBots().size() >= botConfigSize) { + this.client.getHabbo().alert(Emulator.getTexts().getValue("hotel.bot.max.amount.message").replace("%amount%", botConfigSize + "")); + return; + } + } if (page instanceof PetsLayout) { // checks it's the petlayout String[] check = extraData.split("\n"); // splits the extradata if ((check.length != 3) || (check[0].length() < PET_NAME_LENGTH_MINIMUM) || (check[0].length() > PET_NAME_LENGTH_MAXIMUM) || (!StringUtils.isAlphanumeric(check[0])))// checks if there's 3 parts (always is with pets, if not it fucks them off)