Room.java clean-up

This commit is contained in:
Stankman 2023-07-22 21:42:41 -05:00
parent 4d81fc9dd0
commit b80f3da289
59 changed files with 490 additions and 524 deletions

View File

@ -131,7 +131,7 @@ public class BotManager {
RoomBot roomBot = bot.getRoomUnit(); RoomBot roomBot = bot.getRoomUnit();
roomBot.setRotation(RoomRotation.SOUTH); roomBot.setRotation(RoomRotation.SOUTH);
roomBot.setLocation(location); roomBot.setLocation(location);
double stackHeight = room.getTopHeightAt(location.getX(), location.getY()); double stackHeight = room.getRoomItemManager().getTopHeightAt(location.getX(), location.getY());
roomBot.setPreviousLocationZ(stackHeight); roomBot.setPreviousLocationZ(stackHeight);
roomBot.setCurrentZ(stackHeight); roomBot.setCurrentZ(stackHeight);
roomBot.setRoom(room); roomBot.setRoom(room);
@ -150,7 +150,7 @@ public class BotManager {
habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot)); habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot));
bot.onPlace(habbo, room); bot.onPlace(habbo, room);
RoomItem topItem = room.getTopItemAt(location.getX(), location.getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(location.getX(), location.getY());
if (topItem != null) { if (topItem != null) {
try { try {

View File

@ -26,8 +26,8 @@ public class CoordsCommand extends Command {
"Tile State: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getState().name() + "\r" + "Tile State: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getState().name() + "\r" +
"Tile Walkable: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).isWalkable() + "\r" + "Tile Walkable: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).isWalkable() + "\r" +
"Tile relative height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).relativeHeight() + "\r" + "Tile relative height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).relativeHeight() + "\r" +
"Tile stack height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getStackHeight()); "Tile stack height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getStackHeight() + "\r" +
"Tile has Furni: " + (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getItemsAt(gameClient.getHabbo().getRoomUnit().getCurrentPosition()).isEmpty()));
} else { } else {
RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2])); RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2]));

View File

@ -41,7 +41,7 @@ public class BattleBanzaiGameTeam extends GameTeam {
RoomUnit roomUnit = habbo.getRoomUnit(); RoomUnit roomUnit = habbo.getRoomUnit();
Room room = roomUnit.getRoom(); Room room = roomUnit.getRoom();
if(room == null) return; if(room == null) return;
RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;
int nextEffectDuration = -1; int nextEffectDuration = -1;

View File

@ -191,7 +191,7 @@ public class FreezeGame extends Game {
if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) { if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) {
for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) { for (Habbo habbo : this.room.getRoomUnitManager().getRoomHabbos()) {
if (this.getTeamForHabbo(habbo) == null) { if (this.getTeamForHabbo(habbo) == null) {
for (RoomItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentPosition())) { for (RoomItem item : this.room.getRoomItemManager().getItemsAt(habbo.getRoomUnit().getCurrentPosition())) {
if (item instanceof InteractionFreezeTile) { if (item instanceof InteractionFreezeTile) {
RoomItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile(); RoomItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY())); WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY()));

View File

@ -29,7 +29,7 @@ public class FreezeGameTeam extends GameTeam {
Room room = roomUnit.getRoom(); Room room = roomUnit.getRoom();
if(room == null) return; if(room == null) return;
RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;
int nextEffectDuration = -1; int nextEffectDuration = -1;

View File

@ -64,7 +64,7 @@ public abstract class TagGame extends Game {
@EventHandler @EventHandler
public static void onUserWalkEvent(UserTakeStepEvent event) { public static void onUserWalkEvent(UserTakeStepEvent event) {
if (event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) { if (event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) {
THashSet<RoomItem> items = event.habbo.getRoomUnit().getRoom().getItemsAt(event.toLocation); THashSet<RoomItem> items = event.habbo.getRoomUnit().getRoom().getRoomItemManager().getItemsAt(event.toLocation);
TagGame game = (TagGame) event.habbo.getRoomUnit().getRoom().getGame(event.habbo.getHabboInfo().getCurrentGame()); TagGame game = (TagGame) event.habbo.getRoomUnit().getRoom().getGame(event.habbo.getHabboInfo().getCurrentGame());
@ -177,7 +177,7 @@ public abstract class TagGame extends Game {
Room room = roomUnit.getRoom(); Room room = roomUnit.getRoom();
if (room == null) return; if (room == null) return;
RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;
int nextEffectDuration = -1; int nextEffectDuration = -1;

View File

@ -45,7 +45,7 @@ public class WiredGame extends Game {
Room room = this.room; Room room = this.room;
if (room == null) return; if (room == null) return;
RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;
int nextEffectDuration = -1; int nextEffectDuration = -1;

View File

@ -78,7 +78,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (!canBuild.isEmpty()) { if (!canBuild.isEmpty()) {
for (RoomTile tile : this.tiles) { for (RoomTile tile : this.tiles) {
THashSet<RoomItem> tileItems = room.getItemsAt(tile); THashSet<RoomItem> tileItems = room.getRoomItemManager().getItemsAt(tile);
for (RoomItem tileItem : tileItems) { for (RoomItem tileItem : tileItems) {
if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) {
room.getRoomItemManager().pickUpItem(tileItem, null); room.getRoomItemManager().pickUpItem(tileItem, null);
@ -127,7 +127,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (!canBuild.isEmpty()) { if (!canBuild.isEmpty()) {
for (RoomTile tile : this.tiles) { for (RoomTile tile : this.tiles) {
THashSet<RoomItem> tileItems = room.getItemsAt(tile); THashSet<RoomItem> tileItems = room.getRoomItemManager().getItemsAt(tile);
if (newTiles.contains(tile)) continue; if (newTiles.contains(tile)) continue;
for (RoomItem tileItem : tileItems) { for (RoomItem tileItem : tileItems) {
if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) {
@ -202,7 +202,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
} }
if (!canBuild.isEmpty()) { if (!canBuild.isEmpty()) {
for (RoomTile tile : oldTiles) { for (RoomTile tile : oldTiles) {
THashSet<RoomItem> tileItems = room.getItemsAt(tile); THashSet<RoomItem> tileItems = room.getRoomItemManager().getItemsAt(tile);
for (RoomItem tileItem : tileItems) { for (RoomItem tileItem : tileItems) {
if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) { if (canBuild.contains(tileItem.getOwnerId()) && tileItem != this) {
room.getRoomItemManager().pickUpItem(tileItem, null); room.getRoomItemManager().pickUpItem(tileItem, null);

View File

@ -52,7 +52,7 @@ public class InteractionDefault extends RoomItem {
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
super.onMove(room, oldLocation, newLocation); super.onMove(room, oldLocation, newLocation);
if (room.getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) { if (room.getRoomItemManager().getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) {
for (RoomUnit unit : room.getRoomUnitManager().getCurrentRoomUnits().values()) { for (RoomUnit unit : room.getRoomUnitManager().getCurrentRoomUnits().values()) {
if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem()))
continue; // If the unit was previously on the furni... continue; // If the unit was previously on the furni...
@ -165,7 +165,8 @@ public class InteractionDefault extends RoomItem {
if (objects != null && objects.length == 2) { if (objects != null && objects.length == 2) {
if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) { if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) {
RoomItem topItem = room.getTopItemAt(goalTile.getX(), goalTile.getY(), (objects[0] != objects[1]) ? this : null); RoomItem exclude = (objects[0] != objects[1]) ? this : null;
RoomItem topItem = room.getRoomItemManager().getTopItemAt(goalTile.getX(), goalTile.getY(), exclude);
if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) {
return; return;

View File

@ -68,7 +68,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
if (roomUnit != null) { if (roomUnit != null) {
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;
int nextEffectDuration = -1; int nextEffectDuration = -1;

View File

@ -57,7 +57,7 @@ public class InteractionMultiHeight extends RoomItem {
} }
if (objects[0] instanceof Integer && room != null) { if (objects[0] instanceof Integer && room != null) {
RoomItem topItem = room.getTopItemAt(this.getX(), this.getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(this.getX(), this.getY());
if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top
return; return;
} }

View File

@ -9,7 +9,6 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState; import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.entities.RoomEntity;
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
@ -180,25 +179,23 @@ public class InteractionObstacle extends RoomItem implements ICycleable {
} }
for(RoomTile tile : this.middleTiles) { for(RoomTile tile : this.middleTiles) {
for(RoomEntity entity : tile.getEntities()) { for(RoomUnit roomUnit : tile.getRoomUnits()) {
if(!(entity instanceof RoomUnit)) { if(roomUnit == null) {
continue; continue;
} }
RoomUnit unit = (RoomUnit) entity; if(roomUnit.getPath().size() == 0 && !roomUnit.hasStatus(RoomUnitStatus.MOVE)) {
if(roomUnit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue() != this.getRotation())
if(unit.getPath().size() == 0 && !unit.hasStatus(RoomUnitStatus.MOVE)) {
if(unit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue() != this.getRotation())
continue; continue;
RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentPosition(), unit.getBodyRotation().getValue()); RoomTile tileInfront = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), roomUnit.getBodyRotation().getValue());
if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) { if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) {
unit.setGoalLocation(tileInfront); roomUnit.setGoalLocation(tileInfront);
} }
else { else {
RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentPosition(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue()); RoomTile tileBehind = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue());
if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) { if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) {
unit.setGoalLocation(tileBehind); roomUnit.setGoalLocation(tileBehind);
} }
} }
} }

View File

@ -64,9 +64,10 @@ public class InteractionPuzzleBox extends RoomItem {
if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentPosition(), rotation.getValue()))) if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentPosition(), rotation.getValue())))
return; return;
RoomItem item = room.getTopItemAt(tile.getX(), tile.getY()); RoomItem item = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
if (item != null && !room.getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) return; if (item != null && !room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack())
return;
this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false)); this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false));
this.needsUpdate(true); this.needsUpdate(true);

View File

@ -161,7 +161,7 @@ public class InteractionRentableSpace extends RoomItem {
THashSet<RoomItem> items = new THashSet<>(); THashSet<RoomItem> items = new THashSet<>();
for (int i = rect.x; i < rect.x + rect.getWidth(); i++) { for (int i = rect.x; i < rect.x + rect.getWidth(); i++) {
for (int j = rect.y; j < rect.y + rect.getHeight(); j++) { for (int j = rect.y; j < rect.y + rect.getHeight(); j++) {
items.addAll(room.getItemsAt(i, j, this.getZ())); items.addAll(room.getRoomItemManager().getItemsAt(i, j, this.getZ()));
} }
} }

View File

@ -285,7 +285,7 @@ public class InteractionWater extends InteractionDefault {
} }
private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) { private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) {
for (RoomItem item : room.getItemsAt(x, y, z)) { for (RoomItem item : room.getRoomItemManager().getItemsAt(x, y, z)) {
if (item instanceof InteractionWater water) { if (item instanceof InteractionWater water) {
// Take out picked up water from the recalculation. // Take out picked up water from the recalculation.

View File

@ -60,7 +60,8 @@ public class InteractionWaterItem extends InteractionMultiHeight {
for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) { for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) {
for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) { for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) {
boolean tile = false; boolean tile = false;
THashSet<RoomItem> items = room.getItemsAt(room.getLayout().getTile(x, y)); RoomTile tile1 = room.getLayout().getTile(x, y);
THashSet<RoomItem> items = room.getRoomItemManager().getItemsAt(tile1);
for (RoomItem item : items) { for (RoomItem item : items) {
if (item instanceof InteractionWater) { if (item instanceof InteractionWater) {

View File

@ -128,7 +128,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
@Override @Override
public boolean validMove(Room room, RoomTile from, RoomTile to) { public boolean validMove(Room room, RoomTile from, RoomTile to) {
if (to == null) return false; if (to == null) return false;
RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this);
return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
//return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay()))); //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
@ -158,7 +158,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
if (game != null) { if (game != null) {
GameTeam team = game.getTeamForHabbo(habbo); GameTeam team = game.getTeamForHabbo(habbo);
if (team != null) { if (team != null) {
RoomItem item = room.getTopItemAt(to.getX(), to.getY()); RoomItem item = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY());
try { try {
item.onWalkOn(kicker, room, null); item.onWalkOn(kicker, room, null);
} catch (Exception e) { } catch (Exception e) {

View File

@ -149,7 +149,7 @@ public class InteractionFootball extends InteractionPushable {
@Override @Override
public boolean validMove(Room room, RoomTile from, RoomTile to) { public boolean validMove(Room room, RoomTile from, RoomTile to) {
if (to == null || to.getState() == RoomTileState.INVALID) return false; if (to == null || to.getState() == RoomTileState.INVALID) return false;
RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this);
// Move is valid if there isnt any furni yet // Move is valid if there isnt any furni yet
if (topItem == null) { if (topItem == null) {
@ -157,7 +157,7 @@ public class InteractionFootball extends InteractionPushable {
} }
// If any furni on tile is not stackable, move is invalid (tested on 22-03-2022) // If any furni on tile is not stackable, move is invalid (tested on 22-03-2022)
if (room.getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) { if (room.getRoomItemManager().getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) {
return false; return false;
} }
@ -215,8 +215,8 @@ public class InteractionFootball extends InteractionPushable {
return; return;
} }
} }
RoomItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this); RoomItem currentTopItem = room.getRoomItemManager().getTopItemAt(from.getX(), from.getY(), this);
RoomItem topItem = room.getTopItemAt(to.getX(), to.getY(), this); RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this);
if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && topItem instanceof InteractionFootballGoal interactionFootballGoal) { if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && topItem instanceof InteractionFootballGoal interactionFootballGoal) {
GameTeamColors color = interactionFootballGoal.teamColor; GameTeamColors color = interactionFootballGoal.teamColor;
game.onScore(kicker, color); game.onScore(kicker, color);
@ -239,7 +239,7 @@ public class InteractionFootball extends InteractionPushable {
@Override @Override
public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) { public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
RoomItem topItem = room.getTopItemAt(from.getX(), from.getY(), this); RoomItem topItem = room.getRoomItemManager().getTopItemAt(from.getX(), from.getY(), this);
return !((Emulator.getRandom().nextInt(10) >= 3 && room.getRoomUnitManager().hasHabbosAt(to)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1)); return !((Emulator.getRandom().nextInt(10) >= 3 && room.getRoomUnitManager().hasHabbosAt(to)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
} }

View File

@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer; import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
@ -34,7 +35,8 @@ public class InteractionFreezeBlock extends RoomItem {
return; return;
RoomItem item = null; RoomItem item = null;
THashSet<RoomItem> items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
THashSet<RoomItem> items = room.getRoomItemManager().getItemsAt(tile);
for (RoomItem i : items) { for (RoomItem i : items) {
if (i instanceof InteractionFreezeTile) { if (i instanceof InteractionFreezeTile) {

View File

@ -50,7 +50,7 @@ public class InteractionTotemHead extends InteractionDefault {
private void update(Room room, RoomTile tile) { private void update(Room room, RoomTile tile) {
InteractionTotemLegs legs = null; InteractionTotemLegs legs = null;
for(RoomItem item : room.getItemsAt(tile)) { for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) {
if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
legs = (InteractionTotemLegs)item; legs = (InteractionTotemLegs)item;
} }

View File

@ -41,7 +41,7 @@ public class InteractionTotemLegs extends InteractionDefault {
} }
private void updateHead(Room room, RoomTile tile) { private void updateHead(Room room, RoomTile tile) {
for(RoomItem item : room.getItemsAt(tile)) { for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) {
if(item instanceof InteractionTotemHead && item.getZ() > this.getZ()) if(item instanceof InteractionTotemHead && item.getZ() > this.getZ())
((InteractionTotemHead)item).updateTotemState(room); ((InteractionTotemHead)item).updateTotemState(room);
} }

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
@ -39,7 +40,8 @@ public class InteractionTotemPlanet extends InteractionDefault {
InteractionTotemLegs legs = null; InteractionTotemLegs legs = null;
InteractionTotemHead head = null; InteractionTotemHead head = null;
THashSet<RoomItem> items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY())); RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
THashSet<RoomItem> items = room.getRoomItemManager().getItemsAt(tile);
for(RoomItem item : items) { for(RoomItem item : items) {
if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ()) if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())

View File

@ -34,13 +34,13 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
return this.getWiredSettings().getItems(room).stream().allMatch(item -> { return this.getWiredSettings().getItems(room).stream().allMatch(item -> {
double minZ = item.getZ() + Item.getCurrentHeight(item); double minZ = item.getZ() + Item.getCurrentHeight(item);
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
}); });
} else { } else {
return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> {
double minZ = item.getZ() + Item.getCurrentHeight(item); double minZ = item.getZ() + Item.getCurrentHeight(item);
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
}); });
} }
} }

View File

@ -35,14 +35,14 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
return this.getWiredSettings().getItems(room).stream().allMatch(item -> { return this.getWiredSettings().getItems(room).stream().allMatch(item -> {
double minZ = item.getZ() + Item.getCurrentHeight(item); double minZ = item.getZ() + Item.getCurrentHeight(item);
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
}); });
} }
else { else {
return this.getWiredSettings().getItems(room).stream().anyMatch(item -> { return this.getWiredSettings().getItems(room).stream().anyMatch(item -> {
double minZ = item.getZ() + Item.getCurrentHeight(item); double minZ = item.getZ() + Item.getCurrentHeight(item);
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ)); return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
}); });
} }
} }

View File

@ -31,7 +31,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
return false; return false;
} }
THashSet<RoomItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentPosition()); THashSet<RoomItem> itemsAtUser = room.getRoomItemManager().getItemsAt(roomUnit.getCurrentPosition());
return this.getWiredSettings().getItems(room).stream().anyMatch(itemsAtUser::contains); return this.getWiredSettings().getItems(room).stream().anyMatch(itemsAtUser::contains);
} }

View File

@ -75,7 +75,6 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
return; return;
} }
roomBot.getRoom().unIdle(roomBot.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomBot));
room.sendComposer(new AvatarEffectMessageComposer(roomBot, 4).compose()); room.sendComposer(new AvatarEffectMessageComposer(roomBot, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomBot), (long) WiredHandler.TELEPORT_DELAY + 1000); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomBot), (long) WiredHandler.TELEPORT_DELAY + 1000);

View File

@ -57,7 +57,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
if (room.getRoomItemManager().furnitureFitsAt(tile, item, item.getRotation(), true) == FurnitureMovementError.INVALID_MOVE) if (room.getRoomItemManager().furnitureFitsAt(tile, item, item.getRotation(), true) == FurnitureMovementError.INVALID_MOVE)
continue; continue;
RoomItem topItem = room.getTopItemAt(tile.getX(), tile.getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
if (topItem != null && !topItem.getBaseItem().allowStack()) if (topItem != null && !topItem.getBaseItem().allowStack())
continue; continue;

View File

@ -65,7 +65,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
// makes a temporary effect // makes a temporary effect
roomHabbo.getRoom().unIdle(roomHabbo.getRoom().getRoomUnitManager().getHabboByRoomUnit(roomHabbo)); roomHabbo.unIdle();
room.sendComposer(new AvatarEffectMessageComposer(roomHabbo, 4).compose()); room.sendComposer(new AvatarEffectMessageComposer(roomHabbo, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomHabbo), (long) WiredHandler.TELEPORT_DELAY + 1000); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomHabbo), (long) WiredHandler.TELEPORT_DELAY + 1000);

View File

@ -40,7 +40,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg })); Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, roomUnit, room, new Object[]{ msg }));
if (habbo.getRoomUnit().isIdle()) { if (habbo.getRoomUnit().isIdle()) {
habbo.getRoomUnit().getRoom().unIdle(habbo); habbo.getRoomUnit().unIdle();
} }
return true; return true;
} }

View File

@ -16,12 +16,12 @@ import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.rooms.entities.RoomEntity;
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; 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.RoomUnitType;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredHandler;
@ -364,7 +364,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return RoomTileState.INVALID; return RoomTileState.INVALID;
RoomTileState result = RoomTileState.OPEN; RoomTileState result = RoomTileState.OPEN;
THashSet<RoomItem> items = this.getItemsAt(tile); THashSet<RoomItem> items = this.roomItemManager.getItemsAt(tile);
if (items == null) return RoomTileState.INVALID; if (items == null) return RoomTileState.INVALID;
@ -426,7 +426,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void updateRoomUnit(RoomUnit roomUnit) { public void updateRoomUnit(RoomUnit roomUnit) {
RoomItem item = this.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); RoomItem item = this.roomItemManager.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
if ((item == null && !roomUnit.isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit())) if ((item == null && !roomUnit.isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit()))
roomUnit.removeStatus(RoomUnitStatus.SIT); roomUnit.removeStatus(RoomUnitStatus.SIT);
@ -459,7 +459,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void updateHabbosAt(short x, short y, List<Habbo> habbos) { public void updateHabbosAt(short x, short y, List<Habbo> habbos) {
RoomItem item = this.getTopItemAt(x, y); RoomItem item = this.roomItemManager.getTopItemAt(x, y);
for (Habbo habbo : habbos) { for (Habbo habbo : habbos) {
@ -498,7 +498,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void updateBotsAt(short x, short y) { public void updateBotsAt(short x, short y) {
RoomItem topItem = this.getTopItemAt(x, y); RoomItem topItem = this.roomItemManager.getTopItemAt(x, y);
THashSet<RoomUnit> roomUnits = new THashSet<>(); THashSet<RoomUnit> roomUnits = new THashSet<>();
@ -778,8 +778,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<RoomUnit> updatedUnit = new THashSet<>(); THashSet<RoomUnit> updatedUnit = new THashSet<>();
ArrayList<Habbo> toKick = new ArrayList<>(); ArrayList<Habbo> toKick = new ArrayList<>();
final Room room = this;
final long millis = System.currentTimeMillis(); final long millis = System.currentTimeMillis();
for (Habbo habbo : this.roomUnitManager.getCurrentRoomHabbos().values()) { for (Habbo habbo : this.roomUnitManager.getCurrentRoomHabbos().values()) {
@ -802,14 +800,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
habbo.getRoomUnit().setKickCount(habbo.getRoomUnit().getKickCount() + 1); habbo.getRoomUnit().setKickCount(habbo.getRoomUnit().getKickCount() + 1);
if (habbo.getRoomUnit().getKickCount() >= 5) { if (habbo.getRoomUnit().getKickCount() >= 5) {
this.scheduledTasks.add(() -> Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room)); this.scheduledTasks.add(() -> Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this));
continue; continue;
} }
} }
if (Emulator.getConfig().getBoolean("hotel.rooms.auto.idle")) { if (Emulator.getConfig().getBoolean("hotel.rooms.auto.idle")) {
if (!habbo.getRoomUnit().isIdle()) { if (!habbo.getRoomUnit().isIdle()) {
habbo.getRoomUnit().increaseIdleTimer(); habbo.getRoomUnit().incrementIdleTicks();
if (habbo.getRoomUnit().isIdle()) { if (habbo.getRoomUnit().isIdle()) {
boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE); boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE);
@ -819,7 +817,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
} }
} else { } else {
habbo.getRoomUnit().increaseIdleTimer(); habbo.getRoomUnit().incrementIdleTicks();
if (!this.getRoomInfo().isRoomOwner(habbo) && habbo.getRoomUnit().getIdleTicks() >= Room.IDLE_CYCLES_KICK) { if (!this.getRoomInfo().isRoomOwner(habbo) && habbo.getRoomUnit().getIdleTicks() >= Room.IDLE_CYCLES_KICK) {
UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE); UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE);
@ -947,7 +945,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<RoomItem> itemsOnRoller = new THashSet<>(); THashSet<RoomItem> itemsOnRoller = new THashSet<>();
for (RoomItem item : getItemsAt(rollerTile)) { for (RoomItem item : this.roomItemManager.getItemsAt(rollerTile)) {
if (item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) { if (item.getZ() >= roller.getZ() + Item.getCurrentHeight(roller)) {
itemsOnRoller.add(item); itemsOnRoller.add(item);
} }
@ -976,12 +974,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return true; return true;
THashSet<RoomItem> itemsNewTile = new THashSet<>(); THashSet<RoomItem> itemsNewTile = new THashSet<>();
itemsNewTile.addAll(getItemsAt(tileInFront)); itemsNewTile.addAll(this.roomItemManager.getItemsAt(tileInFront));
itemsNewTile.removeAll(itemsOnRoller); itemsNewTile.removeAll(itemsOnRoller);
itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())); itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId()));
RoomItem topItem = Room.this.getTopItemAt(tileInFront.getX(), tileInFront.getY()); RoomItem topItem = this.roomItemManager.getTopItemAt(tileInFront.getX(), tileInFront.getY());
boolean allowUsers = true; boolean allowUsers = true;
boolean allowFurniture = true; boolean allowFurniture = true;
@ -1027,46 +1025,34 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
roomUserRolledEvent = new UserRolledEvent(null, null, null); roomUserRolledEvent = new UserRolledEvent(null, null, null);
} }
ArrayList<RoomEntity> unitsOnTile = new ArrayList<>(rollerTile.getEntities()); ArrayList<RoomUnit> unitsOnTile = new ArrayList<>(rollerTile.getRoomUnits());
for (RoomEntity entity : rollerTile.getEntities()) { for (RoomUnit roomUnit : rollerTile.getRoomUnits()) {
if(!(entity instanceof RoomUnit)) { if (roomUnit instanceof RoomPet) {
continue; Pet pet = this.roomUnitManager.getPetByRoomUnit(roomUnit);
}
RoomUnit unit = (RoomUnit) entity;
if (unit.getRoomUnitType() == RoomUnitType.PET) {
Pet pet = this.roomUnitManager.getPetByRoomUnit(unit);
if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null) { if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null) {
unitsOnTile.remove(unit); unitsOnTile.remove(roomUnit);
} }
} }
} }
THashSet<Integer> usersRolledThisTile = new THashSet<>(); THashSet<Integer> usersRolledThisTile = new THashSet<>();
for (RoomEntity entity : unitsOnTile) { for (RoomUnit roomUnit : unitsOnTile) {
if(!(entity instanceof RoomUnit)) { if (rolledUnitIds.contains(roomUnit.getVirtualId())) continue;
continue;
}
RoomUnit unit = (RoomUnit) entity;
if (rolledUnitIds.contains(unit.getVirtualId())) continue;
if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break; if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break;
if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable())) if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue; continue;
if (unit.hasStatus(RoomUnitStatus.MOVE)) if (roomUnit.hasStatus(RoomUnitStatus.MOVE))
continue; continue;
double newZ = unit.getCurrentZ() + zOffset; double newZ = roomUnit.getCurrentZ() + zOffset;
if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.HABBO) { if (roomUserRolledEvent != null && roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
roomUserRolledEvent = new UserRolledEvent(this.getRoomUnitManager().getHabboByRoomUnit(unit), roller, tileInFront); roomUserRolledEvent = new UserRolledEvent(this.getRoomUnitManager().getHabboByRoomUnit(roomUnit), roller, tileInFront);
Emulator.getPluginManager().fireEvent(roomUserRolledEvent); Emulator.getPluginManager().fireEvent(roomUserRolledEvent);
if (roomUserRolledEvent.isCancelled()) if (roomUserRolledEvent.isCancelled())
@ -1075,8 +1061,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
// horse riding // horse riding
boolean isRiding = false; boolean isRiding = false;
if (unit.getRoomUnitType() == RoomUnitType.HABBO) { if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(unit); Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) { if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) {
RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); RideablePet riding = rollingHabbo.getHabboInfo().getRiding();
if (riding != null) { if (riding != null) {
@ -1084,25 +1070,25 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
newZ = ridingUnit.getCurrentZ() + zOffset; newZ = ridingUnit.getCurrentZ() + zOffset;
rolledUnitIds.add(ridingUnit.getVirtualId()); rolledUnitIds.add(ridingUnit.getVirtualId());
updatedUnit.remove(ridingUnit); updatedUnit.remove(ridingUnit);
messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentPosition(), ridingUnit.getCurrentZ(), tileInFront, newZ, room)); messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentPosition(), ridingUnit.getCurrentZ(), tileInFront, newZ, this));
isRiding = true; isRiding = true;
} }
} }
} }
usersRolledThisTile.add(unit.getVirtualId()); usersRolledThisTile.add(roomUnit.getVirtualId());
rolledUnitIds.add(unit.getVirtualId()); rolledUnitIds.add(roomUnit.getVirtualId());
updatedUnit.remove(unit); updatedUnit.remove(roomUnit);
messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentPosition(), unit.getCurrentZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), room)); messages.add(new RoomUnitOnRollerComposer(roomUnit, roller, roomUnit.getCurrentPosition(), roomUnit.getCurrentZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), this));
if (itemsOnRoller.isEmpty()) { if (itemsOnRoller.isEmpty()) {
RoomItem item = room.getTopItemAt(tileInFront.getX(), tileInFront.getY()); RoomItem item = this.getRoomItemManager().getTopItemAt(tileInFront.getX(), tileInFront.getY());
if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) { if (item != null && itemsNewTile.contains(item) && !itemsOnRoller.contains(item)) {
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
if (unit.getGoalLocation() == rollerTile) { if (roomUnit.getGoalLocation() == rollerTile) {
try { try {
item.onWalkOn(unit, room, new Object[]{rollerTile, tileInFront}); item.onWalkOn(roomUnit, this, new Object[]{rollerTile, tileInFront});
} catch (Exception e) { } catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e); log.error(CAUGHT_EXCEPTION, e);
} }
@ -1111,15 +1097,15 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
if (unit.hasStatus(RoomUnitStatus.SIT)) { if (roomUnit.hasStatus(RoomUnitStatus.SIT)) {
unit.setSitUpdate(true); roomUnit.setSitUpdate(true);
} }
} }
} }
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
for (MessageComposer message : messages) { for (MessageComposer message : messages) {
room.sendComposer(message.compose()); this.sendComposer(message.compose());
} }
messages.clear(); messages.clear();
} }
@ -1145,7 +1131,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
continue; continue;
} }
messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, room)); messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, this));
rollerFurniIds.add(item.getId()); rollerFurniIds.add(item.getId());
} }
} }
@ -1155,7 +1141,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
for (MessageComposer message : messages) { for (MessageComposer message : messages) {
room.sendComposer(message.compose()); this.sendComposer(message.compose());
} }
messages.clear(); messages.clear();
} }
@ -1233,7 +1219,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (!unit.isWalking() && !unit.isCmdSitEnabled()) { if (!unit.isWalking() && !unit.isCmdSitEnabled()) {
RoomTile thisTile = this.getLayout().getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); RoomTile thisTile = this.getLayout().getTile(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY());
RoomItem topItem = this.getTallestChair(thisTile); RoomItem topItem = this.roomItemManager.getTallestChair(thisTile);
if (topItem == null || !topItem.getBaseItem().allowSit()) { if (topItem == null || !topItem.getBaseItem().allowSit()) {
if (unit.hasStatus(RoomUnitStatus.SIT)) { if (unit.hasStatus(RoomUnitStatus.SIT)) {
@ -1254,7 +1240,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
if (!unit.isWalking() && !unit.isCmdLayEnabled()) { if (!unit.isWalking() && !unit.isCmdLayEnabled()) {
RoomItem topItem = this.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); RoomItem topItem = this.roomItemManager.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY());
if (topItem == null || !topItem.getBaseItem().allowLay()) { if (topItem == null || !topItem.getBaseItem().allowLay()) {
if (unit.hasStatus(RoomUnitStatus.LAY)) { if (unit.hasStatus(RoomUnitStatus.LAY)) {
@ -1291,12 +1277,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public Color getBackgroundTonerColor() { public Color getBackgroundTonerColor() {
Color color = new Color(0, 0, 0); Color color = new Color(0, 0, 0);
TIntObjectIterator<RoomItem> iterator = this.roomItems.iterator(); Iterator<RoomItem> iterator = this.roomItemManager.getCurrentItems().values().iterator();
for (int i = this.roomItems.size(); i > 0; i--) { for (int i = this.roomItemManager.getCurrentItems().size(); i > 0; i--) {
try { try {
iterator.advance(); RoomItem object = iterator.next();
RoomItem object = iterator.value();
if (object instanceof InteractionBackgroundToner) { if (object instanceof InteractionBackgroundToner) {
String[] extraData = object.getExtradata().split(":"); String[] extraData = object.getExtradata().split(":");
@ -1435,7 +1420,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public List<RoomItem> getPostItNotes() { public List<RoomItem> getPostItNotes() {
return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList(); return this.roomItemManager.getCurrentItems().values().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList();
} }
public void kickHabbo(Habbo habbo, boolean alert) { public void kickHabbo(Habbo habbo, boolean alert) {
@ -1556,7 +1541,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
RoomItem doorTileTopItem = this.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY()); RoomItem doorTileTopItem = this.roomItemManager.getTopItemAt(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY());
if (doorTileTopItem != null && !(doorTileTopItem instanceof InteractionTeleportTile)) { if (doorTileTopItem != null && !(doorTileTopItem instanceof InteractionTeleportTile)) {
try { try {
doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{});
@ -1608,7 +1593,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
Emulator.getPluginManager().fireEvent(event); Emulator.getPluginManager().fireEvent(event);
if (!event.isCancelled() && !event.isIdle()) { if (!event.isCancelled() && !event.isIdle()) {
this.unIdle(habbo); habbo.getRoomUnit().unIdle();
} }
this.sendComposer(new UserTypingMessageComposer(habbo.getRoomUnit(), false).compose()); this.sendComposer(new UserTypingMessageComposer(habbo.getRoomUnit(), false).compose());
@ -1839,14 +1824,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public THashSet<RoomTile> getLockedTiles() { public THashSet<RoomTile> getLockedTiles() {
THashSet<RoomTile> lockedTiles = new THashSet<>(); THashSet<RoomTile> lockedTiles = new THashSet<>();
TIntObjectIterator<RoomItem> iterator = this.roomItems.iterator(); Iterator<RoomItem> iterator = this.roomItemManager.getCurrentItems().values().iterator();
for (int i = this.roomItems.size(); i-- > 0; ) { for (int i = this.roomItemManager.getCurrentItems().size(); i-- > 0; ) {
RoomItem item; RoomItem item;
try { try {
iterator.advance(); item = iterator.next();
item = iterator.value();
} catch (Exception e) { } catch (Exception e) {
break; break;
} }
@ -1884,214 +1868,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return lockedTiles; return lockedTiles;
} }
@Deprecated
public THashSet<RoomItem> getItemsAt(int x, int y) {
RoomTile tile = this.getLayout().getTile((short) x, (short) y);
if (tile != null) {
return this.getItemsAt(tile);
}
return new THashSet<>(0);
}
public THashSet<RoomItem> getItemsAt(RoomTile tile) {
return getItemsAt(tile, false);
}
public THashSet<RoomItem> getItemsAt(RoomTile tile, boolean returnOnFirst) {
THashSet<RoomItem> items = new THashSet<>(0);
if (tile == null) {
return items;
}
if (this.loaded) {
THashSet<RoomItem> cachedItems = this.tileCache.get(tile);
if (cachedItems != null)
return cachedItems;
}
TIntObjectIterator<RoomItem> iterator = this.roomItems.iterator();
for (int i = this.roomItems.size(); i-- > 0; ) {
RoomItem item;
try {
iterator.advance();
item = iterator.value();
} catch (Exception e) {
break;
}
if (item == null)
continue;
if (item.getBaseItem().getType() != FurnitureType.FLOOR)
continue;
int width, length;
if (item.getRotation() != 2 && item.getRotation() != 6) {
width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
} else {
width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
}
if (!(tile.getX() >= item.getX() && tile.getX() <= item.getX() + width - 1 && tile.getY() >= item.getY() && tile.getY() <= item.getY() + length - 1))
continue;
items.add(item);
if (returnOnFirst) {
return items;
}
}
if (this.loaded) {
this.tileCache.put(tile, items);
}
return items;
}
public THashSet<RoomItem> getItemsAt(int x, int y, double minZ) {
THashSet<RoomItem> items = new THashSet<>();
for (RoomItem item : this.getItemsAt(x, y)) {
if (item.getZ() < minZ)
continue;
items.add(item);
}
return items;
}
public THashSet<RoomItem> getItemsAt(Class<? extends RoomItem> type, int x, int y) {
THashSet<RoomItem> items = new THashSet<>();
for (RoomItem item : this.getItemsAt(x, y)) {
if (!item.getClass().equals(type))
continue;
items.add(item);
}
return items;
}
public boolean hasItemsAt(int x, int y) {
RoomTile tile = this.getLayout().getTile((short) x, (short) y);
if (tile == null)
return false;
return !this.getItemsAt(tile, true).isEmpty();
}
public RoomItem getTopItemAt(RoomTile tile) {
if(tile == null) {
return null;
}
return this.getTopItemAt(tile.getX(), tile.getY(), null);
}
public RoomItem getTopItemAt(int x, int y) {
return this.getTopItemAt(x, y, null);
}
public RoomItem getTopItemAt(int x, int y, RoomItem exclude) {
RoomTile tile = this.getLayout().getTile((short) x, (short) y);
if (tile == null)
return null;
RoomItem highestItem = null;
for (RoomItem item : this.getItemsAt(x, y)) {
if (exclude != null && exclude == item)
continue;
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
continue;
highestItem = item;
}
return highestItem;
}
public RoomItem getTopItemAt(THashSet<RoomTile> tiles, RoomItem exclude) {
RoomItem highestItem = null;
for (RoomTile tile : tiles) {
if (tile == null)
continue;
for (RoomItem item : this.getItemsAt(tile.getX(), tile.getY())) {
if (exclude != null && exclude == item)
continue;
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
continue;
highestItem = item;
}
}
return highestItem;
}
public double getTopHeightAt(int x, int y) {
RoomItem item = this.getTopItemAt(x, y);
if (item != null) {
return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0));
} else {
return this.layout.getHeightAtSquare(x, y);
}
}
public RoomItem getLowestChair(RoomTile tile) {
RoomItem lowestChair = null;
THashSet<RoomItem> items = this.getItemsAt(tile);
if (items != null && !items.isEmpty()) {
for (RoomItem item : items) {
if (!item.getBaseItem().allowSit())
continue;
if (lowestChair != null && lowestChair.getZ() < item.getZ())
continue;
lowestChair = item;
}
}
return lowestChair;
}
public RoomItem getTallestChair(RoomTile tile) {
RoomItem lowestChair = null;
THashSet<RoomItem> items = this.getItemsAt(tile);
if (items != null && !items.isEmpty()) {
for (RoomItem item : items) {
if (!item.getBaseItem().allowSit())
continue;
if (lowestChair != null && lowestChair.getZ() + Item.getCurrentHeight(lowestChair) > item.getZ() + Item.getCurrentHeight(item))
continue;
lowestChair = item;
}
}
return lowestChair;
}
public double getStackHeight(short x, short y, boolean calculateHeightmap, RoomItem exclude) { public double getStackHeight(short x, short y, boolean calculateHeightmap, RoomItem exclude) {
if (x < 0 || y < 0 || this.layout == null) if (x < 0 || y < 0 || this.layout == null)
@ -2107,7 +1883,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
double height = this.layout.getHeightAtSquare(x, y); double height = this.layout.getHeightAtSquare(x, y);
boolean canStack = true; boolean canStack = true;
THashSet<RoomItem> stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y); THashSet<RoomItem> stackHelpers = this.roomItemManager.getItemsAt(InteractionStackHelper.class, x, y);
for (RoomItem item : stackHelpers) { for (RoomItem item : stackHelpers) {
@ -2116,7 +1892,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
RoomItem item = this.getTopItemAt(x, y, exclude); RoomItem item = this.roomItemManager.getTopItemAt(x, y, exclude);
if (item != null) { if (item != null) {
canStack = item.getBaseItem().allowStack(); canStack = item.getBaseItem().allowStack();
height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item));
@ -2134,7 +1910,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public boolean hasObjectTypeAt(Class<?> type, int x, int y) { public boolean hasObjectTypeAt(Class<?> type, int x, int y) {
THashSet<RoomItem> items = this.getItemsAt(x, y); THashSet<RoomItem> items = this.roomItemManager.getItemsAt(x, y);
for (RoomItem item : items) { for (RoomItem item : items) {
if (item.getClass() == type) { if (item.getClass() == type) {
@ -2155,7 +1931,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (this.roomUnitManager.hasHabbosAt(tile)) if (this.roomUnitManager.hasHabbosAt(tile))
return false; return false;
THashSet<RoomItem> items = this.getItemsAt(x, y); THashSet<RoomItem> items = this.roomItemManager.getItemsAt(x, y);
return this.canSitAt(items) || this.canLayAt(items); return this.canSitAt(items) || this.canLayAt(items);
} }
@ -2170,7 +1946,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (this.roomUnitManager.hasHabbosAt(tile)) if (this.roomUnitManager.hasHabbosAt(tile))
return false; return false;
return this.canSitAt(this.getItemsAt(x, y)); return this.canSitAt(this.roomItemManager.getItemsAt(x, y));
} }
boolean canWalkAt(RoomTile roomTile) { boolean canWalkAt(RoomTile roomTile) {
@ -2183,7 +1959,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
RoomItem topItem = null; RoomItem topItem = null;
boolean canWalk = true; boolean canWalk = true;
THashSet<RoomItem> items = this.getItemsAt(roomTile); THashSet<RoomItem> items = this.roomItemManager.getItemsAt(roomTile);
if (items != null) { if (items != null) {
for (RoomItem item : items) { for (RoomItem item : items) {
if (topItem == null) { if (topItem == null) {
@ -2225,7 +2001,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public boolean canLayAt(RoomTile tile) { public boolean canLayAt(RoomTile tile) {
return this.canLayAt(this.getItemsAt(tile)); return this.canLayAt(this.roomItemManager.getItemsAt(tile));
} }
boolean canLayAt(THashSet<RoomItem> items) { boolean canLayAt(THashSet<RoomItem> items) {
@ -2443,24 +2219,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
public void idle(Habbo habbo) {
habbo.getRoomUnit().setIdle();
if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) {
habbo.getRoomUnit().setDance(DanceType.NONE);
}
this.sendComposer(new SleepMessageComposer(habbo.getRoomUnit()).compose());
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
}
public void unIdle(Habbo habbo) {
if (habbo == null || habbo.getRoomUnit() == null) return;
habbo.getRoomUnit().resetIdleTimer();
this.sendComposer(new SleepMessageComposer(habbo.getRoomUnit()).compose());
WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
}
public void addToWordFilter(String word) { public void addToWordFilter(String word) {
synchronized (this.wordFilterWords) { synchronized (this.wordFilterWords) {
if (this.wordFilterWords.contains(word)) if (this.wordFilterWords.contains(word))

View File

@ -375,7 +375,7 @@ public class RoomItemManager {
boolean magicTile = item instanceof InteractionStackHelper; boolean magicTile = item instanceof InteractionStackHelper;
Optional<RoomItem> stackHelper = this.room.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); Optional<RoomItem> stackHelper = this.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny();
//Check if can be placed at new position //Check if can be placed at new position
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
@ -387,12 +387,12 @@ public class RoomItemManager {
return fits; return fits;
} }
RoomItem topItem = this.room.getTopItemAt(occupiedTiles, null); RoomItem topItem = this.getTopItemAt(occupiedTiles, null);
if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
if (oldLocation != targetTile) { if (oldLocation != targetTile) {
for (RoomTile t : occupiedTiles) { for (RoomTile t : occupiedTiles) {
RoomItem tileTopItem = this.room.getTopItemAt(t.getX(), t.getY()); RoomItem tileTopItem = this.getTopItemAt(t.getX(), t.getY());
if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() ||
(tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.room.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.room.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
return FurnitureMovementError.CANT_STACK; return FurnitureMovementError.CANT_STACK;
@ -414,7 +414,7 @@ public class RoomItemManager {
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>(); List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
for (RoomTile t : occupiedTiles) { for (RoomTile t : occupiedTiles) {
tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
} }
if (!magicTile && !item.canStackAt(tileFurniList)) { if (!magicTile && !item.canStackAt(tileFurniList)) {
@ -670,14 +670,14 @@ public class RoomItemManager {
} }
} }
Optional<RoomItem> stackHelper = this.room.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); Optional<RoomItem> stackHelper = this.getItemsAt(targetTile).stream().filter(InteractionStackHelper.class::isInstance).findAny();
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>(); List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
for (RoomTile t : occupiedTiles) { for (RoomTile t : occupiedTiles) {
tileFurniList.add(Pair.create(t, this.room.getItemsAt(t))); tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
RoomItem topItem = this.room.getTopItemAt(t.getX(), t.getY(), item); RoomItem topItem = this.getTopItemAt(t.getX(), t.getY(), item);
if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) { if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
return FurnitureMovementError.CANT_STACK; return FurnitureMovementError.CANT_STACK;
} }
@ -694,6 +694,211 @@ public class RoomItemManager {
return FurnitureMovementError.NONE; return FurnitureMovementError.NONE;
} }
@Deprecated
public THashSet<RoomItem> getItemsAt(int x, int y) {
RoomTile tile = this.room.getLayout().getTile((short) x, (short) y);
if (tile != null) {
return this.getItemsAt(tile);
}
return new THashSet<>(0);
}
public THashSet<RoomItem> getItemsAt(RoomTile tile) {
return getItemsAt(tile, false);
}
public THashSet<RoomItem> getItemsAt(RoomTile tile, boolean returnOnFirst) {
THashSet<RoomItem> items = new THashSet<>(0);
if (tile == null) {
return items;
}
if (this.room.isLoaded()) {
THashSet<RoomItem> cachedItems = this.room.tileCache.get(tile);
if (cachedItems != null)
return cachedItems;
}
Iterator<RoomItem> iterator = this.currentItems.values().iterator();
for (int i = this.currentItems.size(); i-- > 0; ) {
RoomItem item;
try {
item = iterator.next();
} catch (Exception e) {
break;
}
if (item == null || item.getBaseItem().getType() != FurnitureType.FLOOR) {
continue;
}
int width, length;
if (item.getRotation() != 2 && item.getRotation() != 6) {
width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
} else {
width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
}
if (!(tile.getX() >= item.getX() && tile.getX() <= item.getX() + width - 1 && tile.getY() >= item.getY() && tile.getY() <= item.getY() + length - 1))
continue;
items.add(item);
if (returnOnFirst) {
return items;
}
}
if (this.room.isLoaded()) {
this.room.tileCache.put(tile, items);
}
return items;
}
public THashSet<RoomItem> getItemsAt(int x, int y, double minZ) {
THashSet<RoomItem> items = new THashSet<>();
for (RoomItem item : this.getItemsAt(x, y)) {
if (item.getZ() < minZ)
continue;
items.add(item);
}
return items;
}
public THashSet<RoomItem> getItemsAt(Class<? extends RoomItem> type, int x, int y) {
THashSet<RoomItem> items = new THashSet<>();
for (RoomItem item : this.getItemsAt(x, y)) {
if (!item.getClass().equals(type))
continue;
items.add(item);
}
return items;
}
public boolean hasItemsAt(int x, int y) {
RoomTile tile = this.room.getLayout().getTile((short) x, (short) y);
if (tile == null)
return false;
return !this.getItemsAt(tile, true).isEmpty();
}
public RoomItem getTopItemAt(RoomTile tile) {
if(tile == null) {
return null;
}
return this.getTopItemAt(tile.getX(), tile.getY(), null);
}
public RoomItem getTopItemAt(int x, int y) {
return this.getTopItemAt(x, y, null);
}
public RoomItem getTopItemAt(int x, int y, RoomItem exclude) {
RoomTile tile = this.room.getLayout().getTile((short) x, (short) y);
if (tile == null)
return null;
RoomItem highestItem = null;
for (RoomItem item : this.getItemsAt(x, y)) {
if (exclude != null && exclude == item)
continue;
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
continue;
highestItem = item;
}
return highestItem;
}
public RoomItem getTopItemAt(THashSet<RoomTile> tiles, RoomItem exclude) {
RoomItem highestItem = null;
for (RoomTile tile : tiles) {
if (tile == null)
continue;
for (RoomItem item : this.getItemsAt(tile.getX(), tile.getY())) {
if (exclude != null && exclude == item)
continue;
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
continue;
highestItem = item;
}
}
return highestItem;
}
public double getTopHeightAt(int x, int y) {
RoomItem item = this.getTopItemAt(x, y);
if (item != null) {
return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0));
} else {
return this.room.getLayout().getHeightAtSquare(x, y);
}
}
public RoomItem getLowestChair(RoomTile tile) {
RoomItem lowestChair = null;
THashSet<RoomItem> items = this.getItemsAt(tile);
if (items != null && !items.isEmpty()) {
for (RoomItem item : items) {
if (!item.getBaseItem().allowSit())
continue;
if (lowestChair != null && lowestChair.getZ() < item.getZ())
continue;
lowestChair = item;
}
}
return lowestChair;
}
public RoomItem getTallestChair(RoomTile tile) {
RoomItem lowestChair = null;
THashSet<RoomItem> items = this.getItemsAt(tile);
if (items != null && !items.isEmpty()) {
for (RoomItem item : items) {
if (!item.getBaseItem().allowSit())
continue;
if (lowestChair != null && lowestChair.getZ() + Item.getCurrentHeight(lowestChair) > item.getZ() + Item.getCurrentHeight(item))
continue;
lowestChair = item;
}
}
return lowestChair;
}
public void addCycleTask(ICycleable task) { public void addCycleTask(ICycleable task) {
this.cycleTasks.add(task); this.cycleTasks.add(task);
} }

View File

@ -588,7 +588,7 @@ public class RoomManager {
if(spawnLocation != null) { if(spawnLocation != null) {
roomHabbo.setCanLeaveRoomByDoor(false); roomHabbo.setCanLeaveRoomByDoor(false);
roomHabbo.setTeleporting(true); roomHabbo.setTeleporting(true);
RoomItem topItem = room.getTopItemAt(spawnLocation); RoomItem topItem = room.getRoomItemManager().getTopItemAt(spawnLocation);
if(topItem != null) { if(topItem != null) {
spawnDirection = RoomRotation.values()[topItem.getRotation()]; spawnDirection = RoomRotation.values()[topItem.getRotation()];
@ -674,7 +674,7 @@ public class RoomManager {
} }
} }
roomHabbo.resetIdleTimer(); roomHabbo.resetIdleTicks();
roomHabbo.setInvisible(false); roomHabbo.setInvisible(false);
room.getRoomUnitManager().addRoomUnit(habbo); room.getRoomUnitManager().addRoomUnit(habbo);

View File

@ -1,7 +1,7 @@
package com.eu.habbo.habbohotel.rooms; package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.entities.RoomEntity; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -17,7 +17,8 @@ public class RoomTile {
private final short y; private final short y;
@Getter @Getter
private final short z; private final short z;
private final HashSet<RoomEntity> units; private final HashSet<RoomUnit> roomUnits;
private final HashSet<RoomItem> roomItems;
@Setter @Setter
@Getter @Getter
private RoomTileState state; private RoomTileState state;
@ -39,7 +40,8 @@ public class RoomTile {
this.stackHeight = z; this.stackHeight = z;
this.state = state; this.state = state;
this.setAllowStack(allowStack); this.setAllowStack(allowStack);
this.units = new HashSet<>(); this.roomUnits = new HashSet<>();
this.roomItems = new HashSet<>();
} }
public RoomTile(RoomTile tile) { public RoomTile(RoomTile tile) {
@ -56,20 +58,8 @@ public class RoomTile {
if (this.state == RoomTileState.INVALID) { if (this.state == RoomTileState.INVALID) {
this.allowStack = false; this.allowStack = false;
} }
this.units = tile.units; this.roomUnits = tile.roomUnits;
} this.roomItems = tile.roomItems;
public RoomTile() {
x = 0;
y = 0;
z = 0;
this.stackHeight = 0;
this.state = RoomTileState.INVALID;
this.allowStack = false;
this.diagonally = false;
this.gCosts = 0;
this.hCosts = 0;
this.units = null;
} }
public double getStackHeight() { public double getStackHeight() {
@ -175,36 +165,41 @@ public class RoomTile {
return this.x == x && this.y == y; return this.x == x && this.y == y;
} }
public List<RoomEntity> getEntities() { public List<RoomUnit> getRoomUnits() {
synchronized (this.units) { synchronized (this.roomUnits) {
return new ArrayList<>(this.units); return new ArrayList<>(this.roomUnits);
} }
} }
public void addUnit(RoomEntity entity) { public void addRoomUnit(RoomUnit roomUnit) {
synchronized (this.units) { synchronized (this.roomUnits) {
if (!this.units.contains(entity)) { if (!this.roomUnits.contains(roomUnit)) {
this.units.add(entity); this.roomUnits.add(roomUnit);
} }
} }
} }
public void removeUnit(RoomEntity entity) { public void removeUnit(RoomUnit roomUnit) {
synchronized (this.units) { synchronized (this.roomUnits) {
this.units.remove(entity); this.roomUnits.remove(roomUnit);
} }
} }
public boolean hasUnits() { public boolean hasUnits() {
synchronized (this.units) { synchronized (this.roomUnits) {
return this.units.size() > 0; return !this.roomUnits.isEmpty();
} }
} }
public boolean unitIsOnFurniOnTile(RoomUnit unit, Item item) { public boolean unitIsOnFurniOnTile(RoomUnit roomUnit, Item item) {
if ((unit.getCurrentPosition().getX() < this.x || unit.getCurrentPosition().getX() >= this.x + item.getLength())) if ((roomUnit.getCurrentPosition().getX() < this.x || roomUnit.getCurrentPosition().getX() >= this.x + item.getLength())) {
return false; return false;
if (unit.getCurrentPosition().getY() < this.y) return false; }
return unit.getCurrentPosition().getY() < this.y + item.getWidth();
if (roomUnit.getCurrentPosition().getY() < this.y) {
return false;
}
return roomUnit.getCurrentPosition().getY() < this.y + item.getWidth();
} }
} }

View File

@ -307,7 +307,7 @@ public class RoomUnitManager {
roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose()); roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose());
RoomItem item = roomHabbo.getRoom().getTopItemAt(roomHabbo.getCurrentPosition()); RoomItem item = roomHabbo.getRoom().getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition());
if (item != null) { if (item != null) {
try { try {

View File

@ -25,7 +25,5 @@ public interface IRoomEntity {
double getTargetZ(); double getTargetZ();
RoomEntity setTargetZ(double targetZ); RoomEntity setTargetZ(double targetZ);
void setTargetTile(short x, short y);
void incrementTilesMoved(); void incrementTilesMoved();
} }

View File

@ -12,7 +12,7 @@ import java.util.LinkedList;
@Getter @Getter
@Setter @Setter
@Accessors(chain = true) @Accessors(chain = true)
public class RoomEntity implements IRoomEntity { public abstract class RoomEntity implements IRoomEntity {
private Room room; private Room room;
private RoomTile previousPosition; private RoomTile previousPosition;
private double previousZ; private double previousZ;
@ -23,32 +23,6 @@ public class RoomEntity implements IRoomEntity {
private Deque<RoomTile> path = new LinkedList<>(); private Deque<RoomTile> path = new LinkedList<>();
private int tilesMoved; private int tilesMoved;
public RoomEntity setCurrentPosition(RoomTile tile) {
if (this.currentPosition != null) {
this.currentPosition.removeUnit(this);
}
this.currentPosition = tile;
if(this.currentPosition != null) {
tile.addUnit(this);
}
return this;
}
public void setTargetTile(short x, short y) {
RoomTile targetTile = this.getRoom().getLayout().getTile(x, y);
if(this.getCurrentPosition().equals(targetTile)) {
return;
}
if (targetTile.isWalkable()) {
this.setTargetPosition(targetTile);
}
}
public synchronized void incrementTilesMoved() { public synchronized void incrementTilesMoved() {
this.tilesMoved++; this.tilesMoved++;
} }

View File

@ -336,7 +336,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
public void onPickUp(Room room) { public void onPickUp(Room room) {
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
RoomItem topItem2 = room.getTopItemAt(this.getX(), this.getY(), this); RoomItem topItem2 = room.getRoomItemManager().getTopItemAt(this.getX(), this.getY(), this);
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;
@ -370,7 +370,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
RoomItem topItem2 = room.getTopItemAt(oldLocation.getX(), oldLocation.getY(), this); RoomItem topItem2 = room.getRoomItemManager().getTopItemAt(oldLocation.getX(), oldLocation.getY(), this);
int nextEffectM = 0; int nextEffectM = 0;
int nextEffectF = 0; int nextEffectF = 0;

View File

@ -80,7 +80,6 @@ public abstract class RoomUnit extends RoomEntity {
private boolean sitUpdate = false; private boolean sitUpdate = false;
@Setter @Setter
private boolean isKicked; private boolean isKicked;
@Getter
@Setter @Setter
private int kickCount = 0; private int kickCount = 0;
@Getter @Getter
@ -109,8 +108,6 @@ public abstract class RoomUnit extends RoomEntity {
private int previousEffectId; private int previousEffectId;
private int previousEffectEndTimestamp; private int previousEffectEndTimestamp;
private int timeInRoom; private int timeInRoom;
//RoomHabbo
private int idleTicks;
@Getter @Getter
private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
private final THashSet<Integer> overridableTiles; private final THashSet<Integer> overridableTiles;
@ -143,6 +140,21 @@ public abstract class RoomUnit extends RoomEntity {
public abstract boolean cycle(Room room); public abstract boolean cycle(Room room);
@Override
public RoomUnit setCurrentPosition(RoomTile tile) {
if (this.getCurrentPosition() != null) {
this.getCurrentPosition().removeUnit(this);
}
super.setCurrentPosition(tile);
if(this.getCurrentPosition() != null) {
tile.addRoomUnit(this);
}
return this;
}
public void setRotation(RoomRotation rotation) { public void setRotation(RoomRotation rotation) {
this.bodyRotation = rotation; this.bodyRotation = rotation;
this.headRotation = rotation; this.headRotation = rotation;
@ -273,7 +285,7 @@ public abstract class RoomUnit extends RoomEntity {
} }
public void makeStand() { public void makeStand() {
RoomItem item = this.getRoom().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); RoomItem item = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) { if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
this.setCmdStandEnabled(true); this.setCmdStandEnabled(true);
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]); this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
@ -339,22 +351,6 @@ public abstract class RoomUnit extends RoomEntity {
this.timeInRoom = 0; this.timeInRoom = 0;
} }
public void increaseIdleTimer() {
this.idleTicks++;
}
public boolean isIdle() {
return this.idleTicks > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds.
}
public void resetIdleTimer() {
this.idleTicks = 0;
}
public void setIdle() {
this.idleTicks = Room.IDLE_CYCLES + 1;
}
public void lookAtPoint(RoomTile location) { public void lookAtPoint(RoomTile location) {
if (!this.isCanRotate()) { if (!this.isCanRotate()) {
return; return;
@ -388,7 +384,7 @@ public abstract class RoomUnit extends RoomEntity {
public boolean canOverrideTile(RoomTile tile) { public boolean canOverrideTile(RoomTile tile) {
if (tile == null || this.getRoom() == null || this.getRoom().getLayout() == null) return false; if (tile == null || this.getRoom() == null || this.getRoom().getLayout() == null) return false;
if (this.getRoom().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile))) if (this.getRoom().getRoomItemManager().getItemsAt(tile).stream().anyMatch(i -> i.canOverrideTile(this, this.getRoom(), tile)))
return true; return true;
int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12); int tileIndex = (tile.getX() & 0xFF) | (tile.getY() << 12);
@ -412,7 +408,7 @@ public abstract class RoomUnit extends RoomEntity {
public boolean canForcePosture() { public boolean canForcePosture() {
if (this.getRoom() == null) return false; if (this.getRoom() == null) return false;
RoomItem topItem = this.getRoom().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem)); return (!(topItem instanceof InteractionWater) && !(topItem instanceof InteractionWaterItem));
} }

View File

@ -130,13 +130,14 @@ public class RoomAvatar extends RoomUnit {
this.removeStatus(RoomUnitStatus.DEAD); this.removeStatus(RoomUnitStatus.DEAD);
if (habbo != null) { if (habbo != null) {
if (this.isIdle()) { if(this instanceof RoomHabbo roomHabbo) {
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); if (roomHabbo.isIdle()) {
Emulator.getPluginManager().fireEvent(event); UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
Emulator.getPluginManager().fireEvent(event);
if (!event.isCancelled() && !event.isIdle()) { if (!event.isCancelled() && !event.isIdle()) {
room.unIdle(habbo); roomHabbo.unIdle();
this.resetIdleTimer();; }
} }
} }
@ -152,7 +153,7 @@ public class RoomAvatar extends RoomUnit {
} }
} }
RoomItem item = room.getTopItemAt(next.getX(), next.getY()); RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY());
double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight();
if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
@ -172,7 +173,7 @@ public class RoomAvatar extends RoomUnit {
boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); boolean canSitNextTile = room.canSitAt(next.getX(), next.getY());
if (canSitNextTile) { if (canSitNextTile) {
RoomItem tallestChair = room.getTallestChair(next); RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next);
if (tallestChair != null) if (tallestChair != null)
item = tallestChair; item = tallestChair;
@ -190,7 +191,7 @@ public class RoomAvatar extends RoomUnit {
zHeight += 1.0D; zHeight += 1.0D;
} }
RoomItem roomItem = room.getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY())))
roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next});
@ -255,10 +256,13 @@ public class RoomAvatar extends RoomUnit {
this.setCurrentZ(zHeight); this.setCurrentZ(zHeight);
this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY())); this.setCurrentPosition(room.getLayout().getTile(next.getX(), next.getY()));
this.resetIdleTimer();
if(this instanceof RoomHabbo roomHabbo) {
roomHabbo.resetIdleTicks();
}
if(habbo != null) { if(habbo != null) {
RoomItem topItem = room.getTopItemAt(next.getX(), next.getY()); RoomItem topItem = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY());
boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY(); boolean isAtDoor = next.getX() == room.getLayout().getDoorX() && next.getY() == room.getLayout().getDoorY();
boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick"); boolean publicRoomKicks = !room.getRoomInfo().isPublicRoom() || Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick");

View File

@ -2,6 +2,10 @@ package com.eu.habbo.habbohotel.rooms.entities.units.types;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.rooms.users.SleepMessageComposer;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@ -45,14 +49,42 @@ public class RoomHabbo extends RoomAvatar {
this.kickCount++; this.kickCount++;
} }
public void incrementIdleTick() { public void idle() {
this.idleTicks++; this.setIdle();
if (this.getDanceType() != DanceType.NONE) {
this.setDance(DanceType.NONE);
}
this.getRoom().sendComposer(new SleepMessageComposer(this).compose());
WiredHandler.handle(WiredTriggerType.IDLES, this, this.getRoom(), new Object[]{this});
}
public void unIdle() {
this.resetIdleTicks();
this.getRoom().sendComposer(new SleepMessageComposer(this).compose());
WiredHandler.handle(WiredTriggerType.UNIDLES, this, this.getRoom(), new Object[]{this});
} }
public boolean isIdle() { public boolean isIdle() {
return this.idleTicks > Room.IDLE_CYCLES; return this.idleTicks > Room.IDLE_CYCLES;
} }
public void setIdle() {
this.idleTicks = Room.IDLE_CYCLES + 1;
}
public void incrementIdleTicks() {
this.idleTicks++;
}
public void resetIdleTicks() {
this.idleTicks = 0;
}
public RoomUnitType getRoomUnitType() { public RoomUnitType getRoomUnitType() {
return RoomUnitType.HABBO; return RoomUnitType.HABBO;
} }

View File

@ -89,7 +89,7 @@ public class RoomPet extends RoomUnit {
this.removeStatus(RoomUnitStatus.DEAD); this.removeStatus(RoomUnitStatus.DEAD);
RoomItem item = room.getTopItemAt(next.getX(), next.getY()); RoomItem item = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY());
double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight(); double height = next.getStackHeight() - this.getCurrentPosition().getStackHeight();
if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) { if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
@ -109,7 +109,7 @@ public class RoomPet extends RoomUnit {
boolean canSitNextTile = room.canSitAt(next.getX(), next.getY()); boolean canSitNextTile = room.canSitAt(next.getX(), next.getY());
if (canSitNextTile) { if (canSitNextTile) {
RoomItem tallestChair = room.getTallestChair(next); RoomItem tallestChair = room.getRoomItemManager().getTallestChair(next);
if (tallestChair != null) if (tallestChair != null)
item = tallestChair; item = tallestChair;
@ -123,7 +123,7 @@ public class RoomPet extends RoomUnit {
double zHeight = 0.0D; double zHeight = 0.0D;
RoomItem roomItem = room.getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()); RoomItem roomItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))) if (roomItem != null && (roomItem != item || !RoomLayout.pointInSquare(roomItem.getX(), roomItem.getY(), roomItem.getX() + roomItem.getBaseItem().getWidth() - 1, roomItem.getY() + roomItem.getBaseItem().getLength() - 1, next.getX(), next.getY())))
roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next}); roomItem.onWalkOff(this, room, new Object[]{this.getCurrentPosition(), next});

View File

@ -460,7 +460,7 @@ public class Habbo extends Unit implements Runnable {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectGiven")); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectGiven"));
AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned")); AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"));
this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); this.client.getHabbo().getRoomUnit().unIdle();
this.client.getHabbo().getRoomUnit().setDance(DanceType.NONE); this.client.getHabbo().getRoomUnit().setDance(DanceType.NONE);
} }
} }

View File

@ -255,7 +255,7 @@ public class WiredHandler {
public static boolean executeEffectsAtTiles(THashSet<RoomTile> tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) { public static boolean executeEffectsAtTiles(THashSet<RoomTile> tiles, final RoomUnit roomUnit, final Room room, final Object[] stuff) {
for (RoomTile tile : tiles) { for (RoomTile tile : tiles) {
if (room != null) { if (room != null) {
THashSet<RoomItem> items = room.getItemsAt(tile); THashSet<RoomItem> items = room.getRoomItemManager().getItemsAt(tile);
long millis = room.getCycleTimestamp(); long millis = room.getCycleTimestamp();
for (final RoomItem item : items) { for (final RoomItem item : items) {

View File

@ -111,7 +111,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler {
String square = String.valueOf(mapRows[y].charAt(x)); String square = String.valueOf(mapRows[y].charAt(x));
short height; short height;
if (square.equalsIgnoreCase("x") && room.getTopItemAt(x, y) != null) { if (square.equalsIgnoreCase("x") && room.getRoomItemManager().getTopItemAt(x, y) != null) {
errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}"); errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}");
break blockingRoomItemScan; break blockingRoomItemScan;
} else { } else {
@ -124,7 +124,7 @@ public class UpdateFloorPropertiesEvent extends MessageHandler {
} }
} }
if (tile != null && tile.getState() != RoomTileState.INVALID && height != tile.getZ() && room.getTopItemAt(x, y) != null) { if (tile != null && tile.getState() != RoomTileState.INVALID && height != tile.getZ() && room.getRoomItemManager().getTopItemAt(x, y) != null) {
errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}"); errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}");
break blockingRoomItemScan; break blockingRoomItemScan;
} }

View File

@ -36,9 +36,9 @@ public class AvatarExpressionEvent extends MessageHandler {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.isIdle()) { if (event.isIdle()) {
room.idle(habbo); habbo.getRoomUnit().idle();
} else { } else {
room.unIdle(habbo); habbo.getRoomUnit().unIdle();
} }
} }
} else { } else {
@ -46,7 +46,7 @@ public class AvatarExpressionEvent extends MessageHandler {
Emulator.getPluginManager().fireEvent(event); Emulator.getPluginManager().fireEvent(event);
if (!event.isCancelled() && !event.isIdle()) { if (!event.isCancelled() && !event.isIdle()) {
room.unIdle(habbo); habbo.getRoomUnit().unIdle();
} }
} }

View File

@ -19,7 +19,7 @@ public class ChangePostureEvent extends MessageHandler {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (!event.isIdle()) { if (!event.isIdle()) {
this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); this.client.getHabbo().getRoomUnit().unIdle();
} }
} }
} }

View File

@ -36,7 +36,7 @@ public class DanceEvent extends MessageHandler {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (!event.isIdle()) { if (!event.isIdle()) {
this.client.getHabbo().getRoomUnit().getRoom().unIdle(habbo); this.client.getHabbo().getRoomUnit().unIdle();
} }
} }

View File

@ -10,7 +10,7 @@ public class DropCarryItemEvent extends MessageHandler {
Room room = this.client.getHabbo().getRoomUnit().getRoom(); Room room = this.client.getHabbo().getRoomUnit().getRoom();
this.client.getHabbo().getRoomUnit().setHandItem(0); this.client.getHabbo().getRoomUnit().setHandItem(0);
if (room != null) { if (room != null) {
room.unIdle(this.client.getHabbo()); this.client.getHabbo().getRoomUnit().unIdle();
room.sendComposer(new CarryObjectMessageComposer(this.client.getHabbo().getRoomUnit()).compose()); room.sendComposer(new CarryObjectMessageComposer(this.client.getHabbo().getRoomUnit()).compose());
} }
} }

View File

@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.users;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
@ -26,31 +26,31 @@ public class LookToEvent extends MessageHandler {
} }
} }
RoomUnit roomUnit = habbo.getRoomUnit(); RoomHabbo roomHabbo = habbo.getRoomUnit();
if (!roomUnit.isCanWalk()) if (!roomHabbo.isCanWalk())
return; return;
if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) if (roomHabbo.isWalking() || roomHabbo.hasStatus(RoomUnitStatus.MOVE))
return; return;
if (roomUnit.isCmdLayEnabled() || roomUnit.hasStatus(RoomUnitStatus.LAY)) if (roomHabbo.isCmdLayEnabled() || roomHabbo.hasStatus(RoomUnitStatus.LAY))
return; return;
if (roomUnit.isIdle()) if (roomHabbo.isIdle())
return; return;
int x = this.packet.readInt(); int x = this.packet.readInt();
int y = this.packet.readInt(); int y = this.packet.readInt();
if (x == roomUnit.getCurrentPosition().getX()) { if (x == roomHabbo.getCurrentPosition().getX()) {
if (y == roomUnit.getCurrentPosition().getY()) return; if (y == roomHabbo.getCurrentPosition().getY()) return;
} }
RoomTile tile = habbo.getRoomUnit().getRoom().getLayout().getTile((short) x, (short) y); RoomTile tile = habbo.getRoomUnit().getRoom().getLayout().getTile((short) x, (short) y);
if (tile != null) { if (tile != null) {
roomUnit.lookAtPoint(tile); roomHabbo.lookAtPoint(tile);
} }
} }
} }

View File

@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
@ -37,19 +37,19 @@ public class MoveAvatarEvent extends MessageHandler {
} }
// Get Room Habbo object (Unique GUID?) // Get Room Habbo object (Unique GUID?)
RoomUnit roomUnit = this.client.getHabbo().getRoomUnit(); RoomHabbo roomHabbo = this.client.getHabbo().getRoomUnit();
if(roomUnit == null) { if(roomHabbo == null) {
return; return;
} }
// If habbo is teleporting, don't calculate a new path // If habbo is teleporting, don't calculate a new path
if (roomUnit.isTeleporting()) { if (roomHabbo.isTeleporting()) {
return; return;
} }
// If habbo is being kicked don't calculate a new path // If habbo is being kicked don't calculate a new path
if (roomUnit.isKicked()) { if (roomHabbo.isKicked()) {
return; return;
} }
@ -61,13 +61,13 @@ public class MoveAvatarEvent extends MessageHandler {
} }
// Don't calulcate a new path if are already at the end position // Don't calulcate a new path if are already at the end position
if (x == roomUnit.getCurrentPosition().getX() && y == roomUnit.getCurrentPosition().getY()) { if (x == roomHabbo.getCurrentPosition().getX() && y == roomHabbo.getCurrentPosition().getY()) {
return; return;
} }
// If habbo has control (im assuming admin, do something else, but we dont care about this part here) // If habbo has control (im assuming admin, do something else, but we dont care about this part here)
if (roomUnit.getCacheable().get("control") != null) { if (roomHabbo.getCacheable().get("control") != null) {
habbo = (Habbo) roomUnit.getCacheable().get("control"); habbo = (Habbo) roomHabbo.getCacheable().get("control");
if (habbo.getRoomUnit().getRoom() != room) { if (habbo.getRoomUnit().getRoom() != room) {
habbo.getRoomUnit().getCacheable().remove("controller"); habbo.getRoomUnit().getCacheable().remove("controller");
@ -77,20 +77,20 @@ public class MoveAvatarEvent extends MessageHandler {
} }
// Recover roomUnit if necessary // Recover roomUnit if necessary
roomUnit = habbo.getRoomUnit(); roomHabbo = habbo.getRoomUnit();
// If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path // If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.isCanWalk()) { if (roomHabbo != null && roomHabbo.isInRoom() && roomHabbo.isCanWalk()) {
//If teleport command is enabled //If teleport command is enabled
if(roomUnit.isCmdTeleportEnabled()) { if(roomHabbo.isCmdTeleportEnabled()) {
RoomTile t = room.getLayout().getTile((short) x, (short) y); RoomTile t = room.getLayout().getTile((short) x, (short) y);
if (habbo.getHabboInfo().getRiding() != null) { if (habbo.getHabboInfo().getRiding() != null) {
room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, null, roomUnit.getCurrentPosition(), roomUnit.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose()); room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, null, roomHabbo.getCurrentPosition(), roomHabbo.getCurrentZ(), t, t.getStackHeight() + 1.0D, room).compose());
room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose()); room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose());
} else { } else {
room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose()); room.sendComposer(new RoomUnitOnRollerComposer(roomHabbo, t, room).compose());
} }
return; return;
@ -101,14 +101,15 @@ public class MoveAvatarEvent extends MessageHandler {
return; return;
// Reset idle status // Reset idle status
if (roomUnit.isIdle()) { if (roomHabbo.isIdle()) {
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
Emulator.getPluginManager().fireEvent(event); Emulator.getPluginManager().fireEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (!event.isIdle()) { if (!event.isIdle()) {
if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo); if (roomHabbo.getRoom() != null) {
roomUnit.resetIdleTimer(); roomHabbo.unIdle();
}
} }
} }
} }
@ -128,7 +129,7 @@ public class MoveAvatarEvent extends MessageHandler {
} }
if (room.canLayAt(tile)) { if (room.canLayAt(tile)) {
RoomItem bed = room.getTopItemAt(tile.getX(), tile.getY()); RoomItem bed = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
if (bed != null && bed.getBaseItem().allowLay()) { if (bed != null && bed.getBaseItem().allowLay()) {
room.getLayout().getTile(bed.getX(), bed.getY()); room.getLayout().getTile(bed.getX(), bed.getY());
@ -139,17 +140,17 @@ public class MoveAvatarEvent extends MessageHandler {
}; };
if (pillow != null && room.canLayAt(pillow)) { if (pillow != null && room.canLayAt(pillow)) {
roomUnit.setGoalLocation(pillow); roomHabbo.setGoalLocation(pillow);
return; return;
} }
} }
} }
THashSet<RoomItem> items = room.getItemsAt(tile); THashSet<RoomItem> items = room.getRoomItemManager().getItemsAt(tile);
if (items.size() > 0) { if (items.size() > 0) {
for (RoomItem item : items) { for (RoomItem item : items) {
RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile); RoomTile overriddenTile = item.getOverrideGoalTile(roomHabbo, room, tile);
if (overriddenTile == null) { if (overriddenTile == null) {
return; // null cancels the entire event return; // null cancels the entire event
@ -164,7 +165,7 @@ public class MoveAvatarEvent extends MessageHandler {
// This is where we set the end location and begin finding a path // This is where we set the end location and begin finding a path
if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) { if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) {
roomUnit.setGoalLocation(tile); roomHabbo.setGoalLocation(tile);
} }
} }
} }

View File

@ -21,7 +21,7 @@ public class SignEvent extends MessageHandler {
UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId); UserSignEvent event = new UserSignEvent(this.client.getHabbo(), signId);
if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) {
this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.getSign() + ""); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.getSign() + "");
this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo()); this.client.getHabbo().getRoomUnit().unIdle();
if(signId <= 10) { if(signId <= 10) {

View File

@ -36,7 +36,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
this.newLocation = newLocation; this.newLocation = newLocation;
this.newZ = newZ; this.newZ = newZ;
this.room = room; this.room = room;
oldTopItem = this.room.getTopItemAt(oldLocation.getX(), oldLocation.getY()); oldTopItem = this.room.getRoomItemManager().getTopItemAt(oldLocation.getX(), oldLocation.getY());
} }
public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) { public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room) {
@ -70,8 +70,8 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
if (this.roller != null && room.getLayout() != null) { if (this.roller != null && room.getLayout() != null) {
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentPosition() == this.oldLocation) { if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentPosition() == this.oldLocation) {
RoomItem topItem = this.room.getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY()); RoomItem topItem = this.room.getRoomItemManager().getTopItemAt(this.oldLocation.getX(), this.oldLocation.getY());
RoomItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.getX(), this.newLocation.getY()); RoomItem topItemNewLocation = this.room.getRoomItemManager().getTopItemAt(this.newLocation.getX(), this.newLocation.getY());
if (topItem != null && (oldTopItem == null || oldTopItem != topItemNewLocation)) { if (topItem != null && (oldTopItem == null || oldTopItem != topItemNewLocation)) {
try { try {

View File

@ -1,6 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms.users; package com.eu.habbo.messages.outgoing.rooms.users;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
@ -8,14 +8,14 @@ import lombok.AllArgsConstructor;
@AllArgsConstructor @AllArgsConstructor
public class SleepMessageComposer extends MessageComposer { public class SleepMessageComposer extends MessageComposer {
private final RoomUnit roomUnit; private final RoomHabbo roomHabbo;
@Override @Override
protected ServerMessage composeInternal() { protected ServerMessage composeInternal() {
this.response.init(Outgoing.sleepMessageComposer); this.response.init(Outgoing.sleepMessageComposer);
this.response.appendInt(this.roomUnit.getVirtualId()); this.response.appendInt(this.roomHabbo.getVirtualId());
this.response.appendBoolean(this.roomUnit.isIdle()); this.response.appendBoolean(this.roomHabbo.isIdle());
return this.response; return this.response;
} }
} }

View File

@ -19,7 +19,7 @@ public class BanzaiRandomTeleport implements Runnable {
@Override @Override
public void run() { public void run() {
RoomItem topItemNow = this.room.getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); RoomItem topItemNow = this.room.getRoomItemManager().getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY());
RoomTile lastLocation = this.habbo.getCurrentPosition(); RoomTile lastLocation = this.habbo.getCurrentPosition();
RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY()); RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY());
@ -45,7 +45,7 @@ public class BanzaiRandomTeleport implements Runnable {
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
this.habbo.setCanWalk(true); this.habbo.setCanWalk(true);
RoomItem topItemNext = this.room.getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY()); RoomItem topItemNext = this.room.getRoomItemManager().getTopItemAt(this.habbo.getCurrentPosition().getX(), this.habbo.getCurrentPosition().getY());
if(topItemNext != null) { if(topItemNext != null) {
try { try {

View File

@ -21,7 +21,7 @@ public class ClearRentedSpace implements Runnable {
HashSet<RoomItem> items = new HashSet<>(); HashSet<RoomItem> items = new HashSet<>();
for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) { for (RoomTile t : this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())) {
for (RoomItem i : this.room.getItemsAt(t)) { for (RoomItem i : this.room.getRoomItemManager().getItemsAt(t)) {
if (i.getOwnerId() == this.item.getRenterId()) { if (i.getOwnerId() == this.item.getRenterId()) {
items.add(i); items.add(i);
i.setRoomId(0); i.setRoomId(0);

View File

@ -40,7 +40,7 @@ public class RoomTrashing implements Runnable {
if (event.habbo.getRoomUnit().getRoom().equals(INSTANCE.room)) { if (event.habbo.getRoomUnit().getRoom().equals(INSTANCE.room)) {
THashSet<ServerMessage> messages = new THashSet<>(); THashSet<ServerMessage> messages = new THashSet<>();
THashSet<RoomItem> items = INSTANCE.room.getItemsAt(event.toLocation); THashSet<RoomItem> items = INSTANCE.room.getRoomItemManager().getItemsAt(event.toLocation);
int offset = Emulator.getRandom().nextInt(4) + 2; int offset = Emulator.getRandom().nextInt(4) + 2;
@ -56,7 +56,7 @@ public class RoomTrashing implements Runnable {
} }
for (RoomItem item : items) { for (RoomItem item : items) {
double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ();
messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose());
} }
@ -78,11 +78,11 @@ public class RoomTrashing implements Runnable {
RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7); RoomTile s = INSTANCE.room.getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 7);
if (s != null) { if (s != null) {
items = INSTANCE.room.getItemsAt(s); items = INSTANCE.room.getRoomItemManager().getItemsAt(s);
} }
for (RoomItem item : items) { for (RoomItem item : items) {
double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ();
messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose());
} }
@ -101,10 +101,10 @@ public class RoomTrashing implements Runnable {
} }
s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1); s = INSTANCE.getRoom().getLayout().getTileInFront(INSTANCE.habbo.getRoomUnit().getCurrentPosition(), INSTANCE.habbo.getRoomUnit().getBodyRotation().getValue() + 1);
items = INSTANCE.room.getItemsAt(s); items = INSTANCE.room.getRoomItemManager().getItemsAt(s);
for (RoomItem item : items) { for (RoomItem item : items) {
double offsetZ = (INSTANCE.room.getTopHeightAt(t.getX(), t.getY())) - item.getZ(); double offsetZ = (INSTANCE.room.getRoomItemManager().getTopHeightAt(t.getX(), t.getY())) - item.getZ();
messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose()); messages.add(new FloorItemOnRollerComposer(item, null, t, offsetZ, INSTANCE.room).compose());
} }

View File

@ -36,7 +36,7 @@ public class RoomUnitTeleport implements Runnable {
RoomTile lastLocation = this.roomUnit.getCurrentPosition(); RoomTile lastLocation = this.roomUnit.getCurrentPosition();
RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y); RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y);
RoomItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentPosition().getX(), this.roomUnit.getCurrentPosition().getY()); RoomItem topItem = this.room.getRoomItemManager().getTopItemAt(this.roomUnit.getCurrentPosition().getX(), this.roomUnit.getCurrentPosition().getY());
if (topItem != null) { if (topItem != null) {
try { try {
topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this});
@ -59,7 +59,7 @@ public class RoomUnitTeleport implements Runnable {
this.room.updateHabbosAt(newLocation); this.room.updateHabbosAt(newLocation);
this.room.updateBotsAt(newLocation.getX(), newLocation.getY()); this.room.updateBotsAt(newLocation.getX(), newLocation.getY());
topItem = room.getTopItemAt(x, y); topItem = room.getRoomItemManager().getTopItemAt(x, y);
if (topItem != null && roomUnit.getCurrentPosition().equals(room.getLayout().getTile((short) x, (short) y))) { if (topItem != null && roomUnit.getCurrentPosition().equals(room.getLayout().getTile((short) x, (short) y))) {
try { try {
topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this }); topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this });

View File

@ -52,7 +52,7 @@ class FreezeHandleSnowballExplosion implements Runnable {
THashSet<InteractionFreezeTile> freezeTiles = new THashSet<>(); THashSet<InteractionFreezeTile> freezeTiles = new THashSet<>();
for (RoomTile roomTile : tiles) { for (RoomTile roomTile : tiles) {
THashSet<RoomItem> items = this.thrownData.room.getItemsAt(roomTile); THashSet<RoomItem> items = this.thrownData.room.getRoomItemManager().getItemsAt(roomTile);
for (RoomItem freezeTile : items) { for (RoomItem freezeTile : items) {
if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) { if (freezeTile instanceof InteractionFreezeTile || freezeTile instanceof InteractionFreezeBlock) {

View File

@ -60,7 +60,7 @@ class TeleportActionFive implements Runnable {
Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000); Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 1000);
RoomItem teleportTile = this.room.getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY()); RoomItem teleportTile = this.room.getRoomItemManager().getTopItemAt(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY());
if (teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) { if (teleportTile instanceof InteractionTeleportTile && teleportTile != this.currentTeleport) {
try { try {