room unit bot manager

This commit is contained in:
Dominic Bridge 2023-12-08 16:57:53 +00:00
parent aec2bc3201
commit be3e712293
33 changed files with 368 additions and 281 deletions

View File

@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.rooms.constants.RoomUserAction;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
import com.eu.habbo.habbohotel.rooms.bots.entities.RoomBot;
import com.eu.habbo.habbohotel.units.type.Avatar;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;

View File

@ -107,7 +107,7 @@ public class BotManager {
}
bot.onPickUp(habbo, room);
room.getRoomUnitManager().removeBot(bot);
room.getRoomUnitManager().getRoomBotManager().removeBot(bot);
bot.setFollowingHabboId(0);
bot.setOwnerId(botOwnerInfo.getId());
bot.setOwnerName(botOwnerInfo.getUsername());

View File

@ -190,10 +190,10 @@ public class RoomBundleLayout extends SingleBundle {
if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
synchronized (this.room.getRoomUnitManager().getCurrentBots()) {
synchronized (this.room.getRoomUnitManager().getRoomBotManager().getCurrentBots()) {
statement.setInt(1, userId);
statement.setInt(2, roomId);
for (Bot bot : this.room.getRoomUnitManager().getCurrentBots().values()) {
for (Bot bot : this.room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values()) {
statement.setString(3, bot.getName());
statement.setString(4, bot.getMotto());
statement.setString(5, bot.getFigure());

View File

@ -15,9 +15,9 @@ public class BotsCommand extends Command {
if (gameClient.getHabbo().getRoomUnit().getRoom() == null || !gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo()))
return false;
StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentBots().values().size());
StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomBotManager().getCurrentBots().values().size());
for (Bot bot : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentBots().values()) {
for (Bot bot : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomBotManager().getCurrentBots().values()) {
data.append("\r");
data.append("<b>");
data.append(Emulator.getTexts().getValue("generic.bot.name"));

View File

@ -60,7 +60,7 @@ public class InteractionEffectTile extends InteractionPressurePlate {
this.giveEffect(room, roomUnit, habbo.getHabboInfo().getGender());
}
} else if (roomUnit.getRoomUnitType() == RoomUnitType.BOT) {
Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId());
Bot bot = room.getRoomUnitManager().getRoomBotManager().getRoomBotById(roomUnit.getVirtualId());
if (bot != null) {
this.giveEffect(room, roomUnit, bot.getGender());

View File

@ -32,7 +32,7 @@ public class WiredConditionFurniHaveRoom extends InteractionWiredCondition {
}
Collection<Habbo> habbos = room.getRoomUnitManager().getCurrentHabbos().values();
Collection<Bot> bots = room.getRoomUnitManager().getCurrentBots().values();
Collection<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values();
Collection<Pet> pets = room.getRoomUnitManager().getCurrentPets().values();
return this.getWiredSettings().getItems(room).stream().allMatch(item -> {

View File

@ -32,7 +32,7 @@ public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition {
}
Collection<Habbo> habbos = room.getRoomUnitManager().getCurrentHabbos().values();
Collection<Bot> bots = room.getRoomUnitManager().getCurrentBots().values();
Collection<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values();
Collection<Pet> pets = room.getRoomUnitManager().getCurrentPets().values();
return this.getWiredSettings().getItems(room).stream().noneMatch(item -> {

View File

@ -29,7 +29,7 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
String botLook = stringParams[1];
List<Bot> bots = room.getRoomUnitManager().getBotsByName(botName);
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(botName);
if(bots.size() == 0) {
return false;

View File

@ -29,7 +29,7 @@ public class WiredEffectBotFollowRoom extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
List<Bot> bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam());
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(this.getWiredSettings().getStringParam());
if (habbo != null && bots.size() == 1) {
Bot bot = bots.get(0);

View File

@ -38,7 +38,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
}
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
List<Bot> bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam());
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(this.getWiredSettings().getStringParam());
int itemId = this.getWiredSettings().getIntegerParams().get(PARAM_ITEM_ID);
if (habbo != null && bots.size() == 1) {

View File

@ -48,7 +48,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + "");
}
List<Bot> bots = room.getRoomUnitManager().getBotsByName(botName);
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(botName);
if (bots.size() == 1) {
Bot bot = bots.get(0);

View File

@ -47,7 +47,7 @@ public class WiredEffectBotTalkToRoom extends InteractionWiredEffect {
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName())
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + "");
List<Bot> bots = room.getRoomUnitManager().getBotsByName(botName);
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(botName);
if (bots.size() != 1) {
return false;

View File

@ -9,7 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.constants.RoomTileState;
import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
import com.eu.habbo.habbohotel.rooms.bots.entities.RoomBot;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
@ -38,7 +38,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
}
String botName = this.getWiredSettings().getStringParam();
List<Bot> bots = room.getRoomUnitManager().getBotsByName(botName);
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(botName);
if (bots.size() == 0) {
return false;

View File

@ -31,7 +31,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
}
String botName = this.getWiredSettings().getStringParam();
List<Bot> bots = room.getRoomUnitManager().getBotsByName(botName);
List<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getBotsByName(botName);
if (bots.size() == 0) {
return false;

View File

@ -29,7 +29,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
}
if (stuff[0] instanceof RoomItem) {
return this.getWiredSettings().getItems(room).contains(stuff[0]) && room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit);
return this.getWiredSettings().getItems(room).contains(stuff[0]) && room.getRoomUnitManager().getRoomBotManager().getBotsByName(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit);
}
return false;

View File

@ -21,7 +21,7 @@ public class WiredTriggerBotReachedRoom extends InteractionWiredTrigger {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
return room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit);
return room.getRoomUnitManager().getRoomBotManager().getBotsByName(this.getWiredSettings().getStringParam()).stream().anyMatch(bot -> bot.getRoomUnit() == roomUnit);
}
@Override

View File

@ -516,8 +516,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
if (!this.roomUnitManager.getCurrentBots().isEmpty()) {
Iterator<Bot> botIterator = this.roomUnitManager.getCurrentBots().values().iterator();
if (!this.roomUnitManager.getRoomBotManager().getCurrentBots().isEmpty()) {
Iterator<Bot> botIterator = this.roomUnitManager.getRoomBotManager().getCurrentBots().values().iterator();
while(botIterator.hasNext()) {
try {
@ -1196,7 +1196,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
for (short x = item.getCurrentPosition().getX(); x < item.getCurrentPosition().getX() + item.getBaseItem().getLength(); x++) {
for (short y = item.getCurrentPosition().getY(); y < item.getCurrentPosition().getY() + item.getBaseItem().getWidth(); y++) {
RoomTile tile = this.layout.getTile(x, y);
bots.addAll(this.roomUnitManager.getBotsAt(tile));
bots.addAll(this.roomUnitManager.getRoomBotManager().getBotsAt(tile));
}
}
@ -1260,11 +1260,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public void habboEntered(Habbo habbo) {
synchronized (this.roomUnitManager.getCurrentBots()) {
synchronized (this.roomUnitManager.getRoomBotManager().getCurrentBots()) {
if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId())
return;
Iterator<Bot> botIterator = this.roomUnitManager.getCurrentBots().values().iterator();
Iterator<Bot> botIterator = this.roomUnitManager.getRoomBotManager().getCurrentBots().values().iterator();
while (botIterator.hasNext()) {
try {
@ -1494,8 +1494,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) {
synchronized (this.roomUnitManager.getCurrentBots()) {
Iterator<Bot> botIterator = this.roomUnitManager.getCurrentBots().values().iterator();
synchronized (this.roomUnitManager.getRoomBotManager().getCurrentBots()) {
Iterator<Bot> botIterator = this.roomUnitManager.getRoomBotManager().getCurrentBots().values().iterator();
while (botIterator.hasNext()) {
try {

View File

@ -4,7 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.constants.RoomTileState;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
import com.eu.habbo.habbohotel.rooms.bots.entities.RoomBot;
import gnu.trove.set.hash.THashSet;
import lombok.Getter;
import lombok.Setter;

View File

@ -711,14 +711,14 @@ public class RoomManager {
}
habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getCurrentBots().values()));
habbo.getClient().sendResponse(new RoomUsersComposer(room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values()));
if (!room.getRoomUnitManager().getCurrentBots().isEmpty()) {
room.getRoomUnitManager().getCurrentBots().values().stream()
if (!room.getRoomUnitManager().getRoomBotManager().getCurrentBots().isEmpty()) {
room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values().stream()
.filter(b -> !b.getRoomUnit().getDanceType().equals(DanceType.NONE))
.forEach(b -> habbo.getClient().sendResponse(new DanceMessageComposer(b.getRoomUnit())));
room.getRoomUnitManager().getCurrentBots().values()
room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values()
.forEach(b -> habbo.getClient().sendResponse(new UserUpdateComposer(b.getRoomUnit(), b.getRoomUnit().getCurrentZ())));
}

View File

@ -2,33 +2,22 @@ package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.bots.BotManager;
import com.eu.habbo.habbohotel.items.Item;
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.rooms.bots.RoomBotManager;
import com.eu.habbo.habbohotel.rooms.constants.RoomTileState;
import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem;
import com.eu.habbo.habbohotel.units.Unit;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer;
import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer;
import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.bots.BotPickUpEvent;
import com.eu.habbo.plugin.events.bots.BotPlacedEvent;
import gnu.trove.set.hash.THashSet;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@ -50,68 +39,27 @@ public class RoomUnitManager {
private final Room room;
private final ConcurrentHashMap<Integer, RoomUnit> currentRoomUnits;
private final ConcurrentHashMap<Integer, Habbo> currentHabbos;
private final ConcurrentHashMap<Integer, Bot> currentBots;
private final ConcurrentHashMap<Integer, Pet> currentPets;
private volatile int roomUnitCounter;
public final Object roomUnitLock;
private final RoomBotManager roomBotManager;
public RoomUnitManager(Room room) {
this.room = room;
this.currentRoomUnits = new ConcurrentHashMap<>();
this.currentHabbos = new ConcurrentHashMap<>();
this.currentBots = new ConcurrentHashMap<>();
this.currentPets = new ConcurrentHashMap<>();
this.roomUnitCounter = 0;
this.roomUnitLock = new Object();
roomBotManager = new RoomBotManager(this);
}
public synchronized void load(Connection connection) {
this.loadBots(connection);
roomBotManager.loadBots(connection);
this.loadPets(connection);
}
private synchronized void loadBots(Connection connection) {
this.currentBots.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.owner_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.room.getRoomInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set);
if (bot != null) {
bot.getRoomUnit().setRoom(this.room);
RoomTile spawnTile = this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y"));
if(spawnTile == null) {
bot.getRoomUnit().setCanWalk(false);
} else {
if(spawnTile.getState().equals(RoomTileState.INVALID)) {
bot.getRoomUnit().setCanWalk(false);
}
bot.getRoomUnit().setCurrentPosition(spawnTile);
bot.getRoomUnit().setCurrentZ(set.getDouble("z"));
bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]);
bot.getRoomUnit().setSpawnTile(spawnTile);
bot.getRoomUnit().setSpawnHeight(spawnTile.getState().equals(RoomTileState.INVALID) ? 0 : spawnTile.getStackHeight());
}
bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false);
this.addRoomUnit(bot);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error("Caught Exception", e);
}
}
private synchronized void loadPets(Connection connection) {
this.currentPets.clear();
@ -160,7 +108,7 @@ public class RoomUnitManager {
unit.getRoomUnit().getRoom().updateDatabaseUserCount();
}
case BOT -> {
this.currentBots.put(((Bot) unit).getId(), (Bot) unit);
roomBotManager.addBot((Bot)unit);
}
case PET -> {
this.currentPets.put(((Pet) unit).getId(), (Pet) unit);
@ -190,7 +138,7 @@ public class RoomUnitManager {
}
public List<RoomUnit> getAvatarsAt(RoomTile tile) {
return Stream.concat(this.getHabbosAt(tile).stream(), this.getBotsAt(tile).stream()).map(Unit::getRoomUnit).collect(Collectors.toList());
return Stream.concat(this.getHabbosAt(tile).stream(), roomBotManager.getBotsAt(tile).stream()).map(Unit::getRoomUnit).collect(Collectors.toList());
}
public int getRoomHabbosCount() {
@ -256,148 +204,9 @@ public class RoomUnitManager {
}
}
public Bot getRoomBotById(int botId) {
return this.currentBots.get(botId);
}
public List<Bot> getBotsByName(String name) {
synchronized (this.currentBots) {
return currentBots.values().stream().filter(bot -> bot.getName().equalsIgnoreCase(name)).toList();
}
}
public Bot getBotByRoomUnit(RoomUnit roomUnit) {
return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit() == roomUnit).findFirst().orElse(null);
}
public boolean hasBotsAt(RoomTile tile) {
return this.currentBots.values().stream().anyMatch(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile));
}
public Collection<Bot> getBotsAt(RoomTile tile) {
return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet());
}
public void placeBot(Bot bot, Habbo botOwner, int x, int y) {
synchronized (this.currentBots) {
RoomTile spawnTile = room.getLayout().getTile((short) x, (short) y);
if(spawnTile == null || (!spawnTile.isWalkable() && !this.room.canSitOrLayAt(spawnTile)) || this.areRoomUnitsAt(spawnTile)) {
botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE));
return;
}
if (Emulator.getPluginManager().isRegistered(BotPlacedEvent.class, false)) {
Event event = new BotPlacedEvent(bot, spawnTile, botOwner);
Emulator.getPluginManager().fireEvent(event);
if (event.isCancelled()) {
return;
}
}
if(this.currentBots.size() >= Room.MAXIMUM_BOTS && !botOwner.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) {
botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS));
return;
}
RoomBot roomBot = bot.getRoomUnit();
roomBot.setRoom(this.room);
roomBot.setCurrentPosition(spawnTile);
roomBot.setCurrentZ(spawnTile.getStackHeight());
roomBot.setRotation(RoomRotation.SOUTH);
roomBot.setSpawnTile(spawnTile);
roomBot.setSpawnHeight(spawnTile.getState().equals(RoomTileState.INVALID) ? 0 : spawnTile.getStackHeight());
bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
this.addRoomUnit(bot);
this.room.sendComposer(new RoomUsersComposer(bot).compose());
roomBot.instantUpdate();
botOwner.getInventory().getBotsComponent().removeBot(bot);
botOwner.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot));
bot.onPlace(botOwner, room);
}
}
public void updateBotsAt(RoomTile tile) {
Collection<Bot> bots = this.getBotsAt(tile);
if(bots == null || bots.isEmpty()) {
return;
}
RoomItem item = this.room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
bots.forEach(bot -> {
double z = bot.getRoomUnit().getCurrentPosition().getStackHeight();
if (bot.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !bot.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) {
bot.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
}
if (bot.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !bot.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) {
bot.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
}
if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
if(item.getBaseItem().allowSit()) {
bot.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item)));
} else if(item.getBaseItem().allowLay()) {
bot.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item)));
}
bot.getRoomUnit().setCurrentZ(item.getCurrentZ());
bot.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation()));
} else {
bot.getRoomUnit().setCurrentZ(z);
}
});
}
public void pickUpBot(Bot bot, Habbo picker) {
HabboInfo botOwnerInfo = picker == null ? bot.getOwnerInfo() : picker.getHabboInfo();
BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, picker);
Emulator.getPluginManager().fireEvent(pickedUpEvent);
if (pickedUpEvent.isCancelled())
return;
if (picker == null || (bot.getOwnerInfo().getId() == picker.getHabboInfo().getId() || picker.hasPermissionRight(Permission.ACC_ANYROOMOWNER))) {
if (picker != null && !picker.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS) && picker.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) {
picker.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", String.valueOf(BotManager.MAXIMUM_BOT_INVENTORY_SIZE)));
return;
}
bot.onPickUp(picker, this.room);
bot.setFollowingHabboId(0);
//@DEPRECATED
bot.setOwnerId(botOwnerInfo.getId());
bot.setOwnerName(botOwnerInfo.getUsername());
bot.setOwnerInfo(botOwnerInfo);
this.removeBot(bot);
bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
Habbo receiver = picker == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(botOwnerInfo.getId()) : picker;
if (receiver != null) {
receiver.getInventory().getBotsComponent().addBot(bot);
receiver.getClient().sendResponse(new BotAddedToInventoryComposer(bot));
}
}
}
public void placePet(Pet pet, Room room, short x, short y, double z) {
synchronized (this.currentPets) {
@ -476,7 +285,7 @@ public class RoomUnitManager {
synchronized (this.roomUnitLock) {
this.currentHabbos.remove(habbo.getHabboInfo().getId());
this.currentRoomUnits.remove(roomHabbo.getVirtualId());
removeUnit(roomHabbo.getVirtualId());
}
roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose());
@ -510,25 +319,10 @@ public class RoomUnitManager {
roomHabbo.clear();
}
public void removeBot(Bot bot) {
if (this.currentBots.containsKey(bot.getId())) {
//TODO gotta do a method to removeUnit and clear tile
if (bot.getRoomUnit().getCurrentPosition() != null) {
bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit());
}
this.currentBots.remove(bot.getId());
this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId());
bot.getRoomUnit().setRoom(null);
this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose());
}
}
public Pet removePet(int petId) {
Pet pet = this.currentPets.get(petId);
this.currentRoomUnits.remove(pet.getRoomUnit().getVirtualId());
removeUnit(pet.getRoomUnit().getVirtualId());
return this.currentPets.remove(petId);
}
@ -566,7 +360,7 @@ public class RoomUnitManager {
for (Pet pet : removedPets) {
this.currentPets.remove(pet.getId());
this.currentRoomUnits.remove(pet.getRoomUnit().getVirtualId());
removeUnit(pet.getRoomUnit().getVirtualId());
}
}
@ -574,7 +368,7 @@ public class RoomUnitManager {
synchronized (this.roomUnitLock) {
this.currentRoomUnits.clear();
this.currentHabbos.clear();
this.currentBots.clear();
this.roomBotManager.clear();
this.currentPets.clear();
this.roomUnitCounter = 0;
}
@ -587,21 +381,7 @@ public class RoomUnitManager {
this.currentHabbos.clear();
Iterator<Bot> botIterator = this.currentBots.values().iterator();
while(botIterator.hasNext()) {
try {
Bot bot = botIterator.next();
bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
} catch (NoSuchElementException e) {
log.error("Caught Exception", e);
break;
}
}
this.currentBots.clear();
roomBotManager.dispose();
Iterator<Pet> petIterator = this.currentPets.values().iterator();
while(petIterator.hasNext()) {
@ -618,4 +398,8 @@ public class RoomUnitManager {
this.currentPets.clear();
this.currentRoomUnits.clear();
}
public void removeUnit(int virtualId) {
this.currentRoomUnits.remove(virtualId);
}
}

View File

@ -0,0 +1,288 @@
package com.eu.habbo.habbohotel.rooms.bots;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.bots.BotManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnitManager;
import com.eu.habbo.habbohotel.rooms.bots.entities.RoomBot;
import com.eu.habbo.habbohotel.rooms.constants.RoomTileState;
import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomUnitSubManager;
import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer;
import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.bots.BotPickUpEvent;
import com.eu.habbo.plugin.events.bots.BotPlacedEvent;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
@Slf4j
public class RoomBotManager extends RoomUnitSubManager {
private final RoomUnitManager roomUnitManager;
@Getter
private final ConcurrentHashMap<Integer, Bot> currentBots;
public RoomBotManager(RoomUnitManager roomUnitManager) {
super(roomUnitManager);
this.roomUnitManager = roomUnitManager;
currentBots = new ConcurrentHashMap<>();
}
public synchronized void loadBots(Connection connection) {
this.currentBots.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.owner_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.room.getRoomInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set);
if (bot != null) {
bot.getRoomUnit().setRoom(this.room);
RoomTile spawnTile = this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y"));
if (spawnTile == null) {
bot.getRoomUnit().setCanWalk(false);
} else {
if (spawnTile.getState().equals(RoomTileState.INVALID)) {
bot.getRoomUnit().setCanWalk(false);
}
bot.getRoomUnit().setCurrentPosition(spawnTile);
bot.getRoomUnit().setCurrentZ(set.getDouble("z"));
bot.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]);
bot.getRoomUnit().setSpawnTile(spawnTile);
bot.getRoomUnit().setSpawnHeight(spawnTile.getState().equals(RoomTileState.INVALID) ? 0 : spawnTile.getStackHeight());
}
bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false);
this.addBot(bot);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error("Caught Exception", e);
}
}
public Bot getRoomBotById(int botId) {
return this.currentBots.get(botId);
}
public List<Bot> getBotsByName(String name) {
synchronized (this.currentBots) {
return currentBots.values().stream().filter(bot -> bot.getName().equalsIgnoreCase(name)).toList();
}
}
public Bot getBotByRoomUnit(RoomUnit roomUnit) {
return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit() == roomUnit).findFirst().orElse(null);
}
public boolean hasBotsAt(RoomTile tile) {
return this.currentBots.values().stream().anyMatch(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile));
}
public Collection<Bot> getBotsAt(RoomTile tile) {
return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet());
}
public void placeBot(Bot bot, Habbo botOwner, int x, int y) {
synchronized (this.currentBots) {
RoomTile spawnTile = room.getLayout().getTile((short) x, (short) y);
if (spawnTile == null || (!spawnTile.isWalkable() && !this.room.canSitOrLayAt(spawnTile)) || roomUnitManager.areRoomUnitsAt(spawnTile)) {
botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE));
return;
}
if (Emulator.getPluginManager().isRegistered(BotPlacedEvent.class, false)) {
Event event = new BotPlacedEvent(bot, spawnTile, botOwner);
Emulator.getPluginManager().fireEvent(event);
if (event.isCancelled()) {
return;
}
}
if (this.currentBots.size() >= Room.MAXIMUM_BOTS && !botOwner.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) {
botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS));
return;
}
RoomBot roomBot = bot.getRoomUnit();
roomBot.setRoom(this.room);
roomBot.setCurrentPosition(spawnTile);
roomBot.setCurrentZ(spawnTile.getStackHeight());
roomBot.setRotation(RoomRotation.SOUTH);
roomBot.setSpawnTile(spawnTile);
roomBot.setSpawnHeight(spawnTile.getState().equals(RoomTileState.INVALID) ? 0 : spawnTile.getStackHeight());
bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
this.addBot(bot);
this.room.sendComposer(new RoomUsersComposer(bot).compose());
roomBot.instantUpdate();
botOwner.getInventory().getBotsComponent().removeBot(bot);
botOwner.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot));
bot.onPlace(botOwner, room);
}
}
public void updateBotsAt(RoomTile tile) {
Collection<Bot> bots = this.getBotsAt(tile);
if (bots == null || bots.isEmpty()) {
return;
}
RoomItem item = this.room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
bots.forEach(bot -> {
double z = bot.getRoomUnit().getCurrentPosition().getStackHeight();
if (bot.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !bot.getRoomUnit().isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))) {
bot.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
}
if (bot.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !bot.getRoomUnit().isCmdLayEnabled()) || (item != null && !item.getBaseItem().allowLay()))) {
bot.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
}
if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
if (item.getBaseItem().allowSit()) {
bot.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item)));
} else if (item.getBaseItem().allowLay()) {
bot.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item)));
}
bot.getRoomUnit().setCurrentZ(item.getCurrentZ());
bot.getRoomUnit().setRotation(RoomRotation.fromValue(item.getRotation()));
} else {
bot.getRoomUnit().setCurrentZ(z);
}
});
}
public void pickUpBot(Bot bot, Habbo picker) {
HabboInfo botOwnerInfo = picker == null ? bot.getOwnerInfo() : picker.getHabboInfo();
BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, picker);
Emulator.getPluginManager().fireEvent(pickedUpEvent);
if (pickedUpEvent.isCancelled())
return;
if (picker == null || (bot.getOwnerInfo().getId() == picker.getHabboInfo().getId() || picker.hasPermissionRight(Permission.ACC_ANYROOMOWNER))) {
if (picker != null && !picker.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS) && picker.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) {
picker.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", String.valueOf(BotManager.MAXIMUM_BOT_INVENTORY_SIZE)));
return;
}
bot.onPickUp(picker, this.room);
bot.setFollowingHabboId(0);
//@DEPRECATED
bot.setOwnerId(botOwnerInfo.getId());
bot.setOwnerName(botOwnerInfo.getUsername());
bot.setOwnerInfo(botOwnerInfo);
this.removeBot(bot);
bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
Habbo receiver = picker == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(botOwnerInfo.getId()) : picker;
if (receiver != null) {
receiver.getInventory().getBotsComponent().addBot(bot);
receiver.getClient().sendResponse(new BotAddedToInventoryComposer(bot));
}
}
}
public void addBot(Bot unit) {
currentBots.put(unit.getId(), unit);
}
public void removeBot(Bot bot) {
if (this.currentBots.containsKey(bot.getId())) {
//TODO gotta do a method to removeUnit and clear tile
if (bot.getRoomUnit().getCurrentPosition() != null) {
bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit());
}
this.currentBots.remove(bot.getId());
roomUnitManager.removeUnit(bot.getRoomUnit().getVirtualId());
bot.getRoomUnit().setRoom(null);
this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose());
}
}
public void clear() {
currentBots.clear();
}
public void dispose() {
Iterator<Bot> botIterator = this.currentBots.values().iterator();
while (botIterator.hasNext()) {
try {
Bot bot = botIterator.next();
bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
} catch (NoSuchElementException e) {
log.error("Caught Exception", e);
break;
}
}
this.currentBots.clear();
}
}

View File

@ -1,4 +1,4 @@
package com.eu.habbo.habbohotel.rooms.entities.units.types;
package com.eu.habbo.habbohotel.rooms.bots.entities;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.constants.RoomUserAction;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.rooms.users.ChatMessageComposer;

View File

@ -166,7 +166,7 @@ public abstract class RoomUnit extends RoomEntity {
super.setCurrentZ(currentZ);
if (this.room != null) {
Bot bot = this.room.getRoomUnitManager().getRoomBotById(getVirtualId());
Bot bot = this.room.getRoomUnitManager().getRoomBotManager().getRoomBotById(getVirtualId());
if (bot != null) {
bot.setSqlUpdateNeeded(true);
}

View File

@ -0,0 +1,14 @@
package com.eu.habbo.habbohotel.rooms.entities.units.types;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnitManager;
public abstract class RoomUnitSubManager {
protected RoomUnitManager roomUnitManager;
protected Room room;
public RoomUnitSubManager(RoomUnitManager roomUnitManager){
this.roomUnitManager = roomUnitManager;
this.room = roomUnitManager.getRoom();
}
}

View File

@ -263,7 +263,7 @@ public class RoomItemManager {
for (RoomTile t : occupiedTiles) {
this.room.getRoomUnitManager().updateHabbosAt(t);
this.room.getRoomUnitManager().updateBotsAt(t);
this.room.getRoomUnitManager().getRoomBotManager().updateBotsAt(t);
}
Emulator.getThreading().run(item);
@ -343,7 +343,7 @@ public class RoomItemManager {
if (checkForUnits && !magicTile) {
if (this.room.getRoomUnitManager().hasHabbosAt(t))
return FurnitureMovementError.TILE_HAS_HABBOS;
if (!this.room.getRoomUnitManager().getBotsAt(t).isEmpty())
if (!this.room.getRoomUnitManager().getRoomBotManager().getBotsAt(t).isEmpty())
return FurnitureMovementError.TILE_HAS_BOTS;
if (this.room.getRoomUnitManager().hasPetsAt(t))
return FurnitureMovementError.TILE_HAS_PETS;
@ -459,7 +459,7 @@ public class RoomItemManager {
//Update Habbos at old position
for (RoomTile t : occupiedTiles) {
this.room.getRoomUnitManager().updateHabbosAt(t);
this.room.getRoomUnitManager().updateBotsAt(t);
this.room.getRoomUnitManager().getRoomBotManager().updateBotsAt(t);
}
if (Emulator.getConfig().getBoolean("wired.place.under", false)) {
@ -520,7 +520,7 @@ public class RoomItemManager {
updatedTiles.forEach(tile -> {
this.room.getRoomUnitManager().updateHabbosAt(tile);
this.room.getRoomUnitManager().updateBotsAt(tile);
this.room.getRoomUnitManager().getRoomBotManager().updateBotsAt(tile);
});
} else if (roomItem.getBaseItem().getType() == FurnitureType.WALL) {
this.room.sendComposer(new ItemRemoveMessageComposer(roomItem).compose());
@ -606,7 +606,7 @@ public class RoomItemManager {
if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) {
if (checkForUnits && this.room.getRoomUnitManager().hasHabbosAt(occupiedTile))
return FurnitureMovementError.TILE_HAS_HABBOS;
if (checkForUnits && this.room.getRoomUnitManager().hasBotsAt(occupiedTile))
if (checkForUnits && this.room.getRoomUnitManager().getRoomBotManager().hasBotsAt(occupiedTile))
return FurnitureMovementError.TILE_HAS_BOTS;
if (checkForUnits && this.room.getRoomUnitManager().hasPetsAt(occupiedTile))
return FurnitureMovementError.TILE_HAS_PETS;

View File

@ -367,7 +367,7 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
}
RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
for (Bot bot : room.getRoomUnitManager().getBotsAt(tile)) {
for (Bot bot : room.getRoomUnitManager().getRoomBotManager().getBotsAt(tile)) {
if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
bot.getRoomUnit().giveEffect(nextEffectM, -1);
}
@ -397,12 +397,12 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) {
oldHabbos.addAll(room.getRoomUnitManager().getHabbosAt(tile));
oldBots.addAll(room.getRoomUnitManager().getBotsAt(tile));
oldBots.addAll(room.getRoomUnitManager().getRoomBotManager().getBotsAt(tile));
}
for (RoomTile tile : room.getLayout().getTilesAt(oldLocation, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) {
newHabbos.addAll(room.getRoomUnitManager().getHabbosAt(tile));
newBots.addAll(room.getRoomUnitManager().getBotsAt(tile));
newBots.addAll(room.getRoomUnitManager().getRoomBotManager().getBotsAt(tile));
}
oldHabbos.removeAll(newHabbos);

View File

@ -347,7 +347,7 @@ public class Habbo extends Avatar implements Runnable {
public void deleteBot(Bot bot) {
this.removeBot(bot);
bot.getRoomUnit().getRoom().getRoomUnitManager().removeBot(bot);
bot.getRoomUnit().getRoom().getRoomUnitManager().getRoomBotManager().removeBot(bot);
Emulator.getGameEnvironment().getBotManager().deleteBot(bot);
}

View File

@ -50,7 +50,7 @@ public class DeleteRoomEvent extends MessageHandler {
room.getRoomItemManager().ejectAllFurni();
room.getRoomItemManager().ejectUserFurni(room.getRoomInfo().getOwnerInfo().getId());
List<Bot> bots = new ArrayList<>(room.getRoomUnitManager().getCurrentBots().values());
List<Bot> bots = new ArrayList<>(room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values());
for (Bot bot : bots) {
Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room);
}

View File

@ -28,7 +28,7 @@ public class CommandBotEvent extends MessageHandler {
if (room.getRoomInfo().isRoomOwner(this.client.getHabbo()) || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) {
int botId = this.packet.readInt();
Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId));
Bot bot = room.getRoomUnitManager().getRoomBotManager().getRoomBotById(Math.abs(botId));
if (bot == null) {
return;

View File

@ -17,7 +17,7 @@ public class GetBotCommandConfigurationDataEvent extends MessageHandler {
if (room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) {
int botId = this.packet.readInt();
Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId));
Bot bot = room.getRoomUnitManager().getRoomBotManager().getRoomBotById(Math.abs(botId));
if (bot == null)
return;

View File

@ -22,6 +22,6 @@ public class PlaceBotEvent extends MessageHandler {
int x = this.packet.readInt();
int y = this.packet.readInt();
room.getRoomUnitManager().placeBot(bot, this.client.getHabbo(), x, y);
room.getRoomUnitManager().getRoomBotManager().placeBot(bot, this.client.getHabbo(), x, y);
}
}

View File

@ -17,12 +17,12 @@ public class RemoveBotFromFlatEvent extends MessageHandler {
int botId = this.packet.readInt();
Bot bot = room.getRoomUnitManager().getRoomBotById(Math.abs(botId));
Bot bot = room.getRoomUnitManager().getRoomBotManager().getRoomBotById(Math.abs(botId));
if(bot == null) {
return;
}
room.getRoomUnitManager().pickUpBot(bot, this.client.getHabbo());
room.getRoomUnitManager().getRoomBotManager().pickUpBot(bot, this.client.getHabbo());
}
}

View File

@ -55,7 +55,7 @@ public class RoomUnitTeleport implements Runnable {
roomUnit.setWiredTeleporting(false);
this.room.getRoomUnitManager().updateHabbosAt(newLocation);
this.room.getRoomUnitManager().updateBotsAt(newLocation);
this.room.getRoomUnitManager().getRoomBotManager().updateBotsAt(newLocation);
topItem = room.getRoomItemManager().getTopItemAt(x, y);
if (topItem != null && roomUnit.getCurrentPosition().equals(room.getLayout().getTile((short) x, (short) y))) {