From 43a1ca2a306207bf629dbf75a0e3722ffa554bac Mon Sep 17 00:00:00 2001 From: harmonic Date: Thu, 4 Jun 2020 16:44:19 +0100 Subject: [PATCH] Cleanup. --- .../java/com/eu/habbo/habbohotel/bots/BotManager.java | 10 ++++++---- .../messages/incoming/catalog/CatalogBuyItemEvent.java | 8 +++++--- .../messages/incoming/rooms/bots/BotPickupEvent.java | 2 ++ src/main/java/com/eu/habbo/plugin/PluginManager.java | 2 ++ 4 files changed, 15 insertions(+), 7 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 f8f70a49..598db052 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -22,6 +22,8 @@ import java.lang.reflect.Method; import java.sql.*; import java.util.Map; + + public class BotManager { private static final Logger LOGGER = LoggerFactory.getLogger(BotManager.class); @@ -30,7 +32,7 @@ public class BotManager { public static int MAXIMUM_CHAT_SPEED = 604800; public static int MAXIMUM_CHAT_LENGTH = 120; public static int MAXIMUM_NAME_LENGTH = 15; - + public static int MAXIMUM_BOT_INVENTORY_SIZE = 25; public BotManager() throws Exception { long millis = System.currentTimeMillis(); @@ -163,7 +165,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); @@ -172,8 +174,8 @@ public class BotManager { return; if (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) { - if (!habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= botConfigSize) { - habbo.alert(Emulator.getTexts().getValue("hotel.bot.max.amount.message").replace("%amount%", botConfigSize + "")); + if (!habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= MAXIMUM_BOT_INVENTORY_SIZE) { + habbo.alert(Emulator.getTexts().getValue("hotel.bot.max.amount.message").replace("%amount%", MAXIMUM_BOT_INVENTORY_SIZE + "")); } bot.onPickUp(habbo, habbo.getHabboInfo().getCurrentRoom()); 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 1aa80882..3e3e2d80 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 @@ -1,6 +1,7 @@ package com.eu.habbo.messages.incoming.catalog; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.catalog.CatalogPage; @@ -28,6 +29,8 @@ import static com.eu.habbo.messages.incoming.catalog.CheckPetNameEvent.PET_NAME_ import static com.eu.habbo.messages.incoming.catalog.CheckPetNameEvent.PET_NAME_LENGTH_MINIMUM; public class CatalogBuyItemEvent extends MessageHandler { + + @Override public void handle() throws Exception { if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastPurchaseTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { @@ -194,9 +197,8 @@ public class CatalogBuyItemEvent extends MessageHandler { 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(Permission.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 + "")); + 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 + "")); return; } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java index 6adae312..ea04d577 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotPickupEvent.java @@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; public class BotPickupEvent extends MessageHandler { + + @Override public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index d2d7c730..5c8af221 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -150,6 +150,8 @@ public class PluginManager { CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 0); BuyRoomPromotionEvent.ROOM_PROMOTION_BADGE = Emulator.getConfig().getValue("room.promotion.badge", "RADZZ"); + BotManager.MAXIMUM_BOT_INVENTORY_SIZE = Emulator.getConfig().getInt("hotel.bots.max.inventory"); + NewNavigatorEventCategoriesComposer.CATEGORIES.clear(); for (String category : Emulator.getConfig().getValue("navigator.eventcategories", "").split(";")) {