From c49d9248ceb35cfcf9f72f119330e470721106bc Mon Sep 17 00:00:00 2001 From: harmonic Date: Thu, 4 Jun 2020 21:55:38 +0100 Subject: [PATCH] Fixed Pet Inventory limit check on purchasing too. --- sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql | 6 ++++-- .../java/com/eu/habbo/habbohotel/pets/PetManager.java | 1 + .../messages/incoming/catalog/CatalogBuyItemEvent.java | 7 ++++++- .../messages/incoming/rooms/pets/PetPickupEvent.java | 8 +++----- src/main/java/com/eu/habbo/plugin/PluginManager.java | 3 ++- 5 files changed, 16 insertions(+), 9 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 c775ff01..c8e18803 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 @@ -14,5 +14,7 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softki 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'); --- 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%.'); +-- Inventory Limiting +INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('error.bots.max.inventory', 'You can\'t buy or pickup anymore bots until you place some, the maximum amount of bots you are allowed is %amount%.'); + +UPDATE `emulator_texts` SET `value` = 'You\'ve reached the maximum amount of pets in your inventory! The Limit is %amount%!' WHERE `key` = 'error.pets.max.inventory'; 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 6b8b3d77..8294707d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.Map; public class PetManager { + public static int MAXIMUM_PET_INVENTORY_SIZE = 25; private static final Logger LOGGER = LoggerFactory.getLogger(PetManager.class); public static final int[] experiences = new int[]{100, 200, 400, 600, 900, 1300, 1800, 2400, 3200, 4300, 5700, 7600, 10100, 13300, 17500, 23000, 30200, 39600, 51900}; static int[] skins = new int[]{0, 1, 6, 7}; 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 3e3e2d80..8e9e2db1 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 @@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.catalog.ClubOffer; import com.eu.habbo.habbohotel.catalog.layouts.*; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.messages.incoming.MessageHandler; @@ -198,11 +199,15 @@ public class CatalogBuyItemEvent extends MessageHandler { // temp patch, can a dev with better knowledge than me look into this asap pls. if (page instanceof BotsLayout) { if (!this.client.getHabbo().hasPermission(Permission.ACC_UNLIMITED_BOTS) && this.client.getHabbo().getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { - this.client.getHabbo().alert(Emulator.getTexts().getValue("hotel.bot.max.amount.message").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + "")); + this.client.getHabbo().alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + "")); return; } } if (page instanceof PetsLayout) { // checks it's the petlayout + if (!this.client.getHabbo().hasPermission(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { + this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + "")); + return; + } 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) return; // if it does it fucks off. diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java index 29dd53f6..211375c3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PetPickupEvent.java @@ -3,14 +3,12 @@ package com.eu.habbo.messages.incoming.rooms.pets; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; 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.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; -import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; public class PetPickupEvent extends MessageHandler { @Override @@ -26,8 +24,8 @@ public class PetPickupEvent extends MessageHandler { if (pet != null) { if (this.client.getHabbo().getHabboInfo().getId() == pet.getId() || room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { - if (this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= Emulator.getConfig().getInt("hotel.pets.max.inventory") && !this.client.getHabbo().hasPermission("acc_unlimited_pets")) { - this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(Emulator.getTexts().getValue("error.pets.max.inventory"), this.client.getHabbo(), this.client.getHabbo(), RoomChatMessageBubbles.ALERT))); + if (!this.client.getHabbo().hasPermission(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { + this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + "")); return; } diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 5c8af221..50565833 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -19,6 +19,7 @@ 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.pets.PetManager; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboManager; @@ -151,7 +152,7 @@ public class PluginManager { BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE = Emulator.getConfig().getValue("room.promotion.badge", "RADZZ"); BotManager.MAXIMUM_BOT_INVENTORY_SIZE = Emulator.getConfig().getInt("hotel.bots.max.inventory"); - + PetManager.MAXIMUM_PET_INVENTORY_SIZE = Emulator.getConfig().getInt("hotel.pets.max.inventory"); NewNavigatorEventCategoriesComposer.CATEGORIES.clear(); for (String category : Emulator.getConfig().getValue("navigator.eventcategories", "").split(";")) {