Merge branch 'fix-bot-limit' into 'dev'

Fixed Optional Bot & Pet Inventory Limits

See merge request morningstar/Arcturus-Community!221
This commit is contained in:
Harmonic 2020-06-05 11:38:21 -04:00
commit 91f6614978
8 changed files with 35 additions and 10 deletions

View File

@ -13,3 +13,8 @@ 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');
-- 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';

View File

@ -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,6 +165,7 @@ public class BotManager {
}
public void pickUpBot(Bot bot, Habbo habbo) {
if (bot != null && habbo != null) {
BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, habbo);
Emulator.getPluginManager().fireEvent(pickedUpEvent);
@ -171,8 +174,10 @@ 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() >= 15)
if (!habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) {
habbo.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + ""));
return;
}
bot.onPickUp(habbo, habbo.getHabboInfo().getCurrentRoom());
habbo.getHabboInfo().getCurrentRoom().removeBot(bot);

View File

@ -38,12 +38,10 @@ public class Permission {
public static String ACC_MODTOOL_ROOM_INFO = "acc_modtool_room_info";
public static String ACC_MODTOOL_ROOM_LOGS = "acc_modtool_room_logs";
public static String ACC_TRADE_ANYWHERE = "acc_trade_anywhere";
public static String ACC_UPDATE_NOTIFICATIONS = "acc_update_notifications";
public static String ACC_HELPER_USE_GUIDE_TOOL = "acc_helper_use_guide_tool";
public static String ACC_HELPER_GIVE_GUIDE_TOURS = "acc_helper_give_guide_tours";
public static String ACC_HELPER_JUDGE_CHAT_REVIEWS = "acc_helper_judge_chat_reviews";
public static String ACC_FLOORPLAN_EDITOR = "acc_floorplan_editor";
public static String ACC_CAMERA = "acc_camera";
public final String key;
public final PermissionSetting setting;
public Permission(String key, PermissionSetting setting) {

View File

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

View File

@ -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;
@ -29,6 +30,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) {
@ -201,7 +204,17 @@ 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) {
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("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.

View File

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

View File

@ -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(Permission.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;
}

View File

@ -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;
@ -150,6 +151,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");
PetManager.MAXIMUM_PET_INVENTORY_SIZE = Emulator.getConfig().getInt("hotel.pets.max.inventory");
NewNavigatorEventCategoriesComposer.CATEGORIES.clear();
for (String category : Emulator.getConfig().getValue("navigator.eventcategories", "").split(";")) {