🆙 Fix BOTS in catalog and inventory

This commit is contained in:
duckietm
2026-05-27 13:46:17 +02:00
parent 7b7154e68f
commit 539c5b5b96
2 changed files with 26 additions and 7 deletions
@@ -48,6 +48,12 @@ public class Item implements ISerialize {
return item.getName().toLowerCase().startsWith("a0 pet"); return item.getName().toLowerCase().startsWith("a0 pet");
} }
public static boolean isBot(Item item) {
if (item == null) return false;
String name = item.getName();
return name != null && (name.startsWith("bot_") || name.startsWith("rentable_bot_"));
}
public static double getCurrentHeight(HabboItem item) { public static double getCurrentHeight(HabboItem item) {
if (item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) { if (item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) {
if (item.getExtradata().isEmpty()) { if (item.getExtradata().isEmpty()) {
@@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.BotManager;
import com.eu.habbo.habbohotel.catalog.*; import com.eu.habbo.habbohotel.catalog.*;
import com.eu.habbo.habbohotel.catalog.layouts.*; import com.eu.habbo.habbohotel.catalog.layouts.*;
import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.FurnitureType;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport; import com.eu.habbo.habbohotel.rooms.BuildersClubRoomSupport;
@@ -206,15 +207,27 @@ public class CatalogBuyItemEvent extends MessageHandler {
} }
} }
} }
// temp patch, can a dev with better knowledge than me look into this asap pls.
if (page instanceof BotsLayout) { boolean itemHasBot = false;
if (!this.client.getHabbo().hasPermission(Permission.ACC_UNLIMITED_BOTS) && this.client.getHabbo().getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) { boolean itemHasPet = false;
this.client.getHabbo().alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + ""));
return; if (item != null) {
for (Item baseItem : item.getBaseItems()) {
if (baseItem == null) continue;
if (Item.isBot(baseItem)) itemHasBot = true;
if (Item.isPet(baseItem)) itemHasPet = true;
} }
} }
if (page instanceof PetsLayout) {
if (!this.client.getHabbo().hasPermission(Permission.ACC_UNLIMITED_PETS) && this.client.getHabbo().getInventory().getPetsComponent().getPets().size() >= PetManager.MAXIMUM_PET_INVENTORY_SIZE) { if (itemHasBot && !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("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + ""));
return;
}
if (itemHasPet) {
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 + "")); this.client.getHabbo().alert(Emulator.getTexts().getValue("error.pets.max.inventory").replace("%amount%", PetManager.MAXIMUM_PET_INVENTORY_SIZE + ""));
return; return;
} }