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.

This commit is contained in:
harmonic 2020-06-04 14:23:19 +01:00
parent c19ef29cf9
commit d97bc09c11
3 changed files with 15 additions and 3 deletions

View File

@ -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');
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%.');

View File

@ -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);

View File

@ -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)