mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
Room.java Clean-Up
This commit is contained in:
parent
ff2cfc2498
commit
4fee1bccf3
@ -2,6 +2,10 @@ package com.eu.habbo.habbohotel.commands.list;
|
||||
|
||||
import com.eu.habbo.habbohotel.commands.Command;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestCommand extends Command {
|
||||
public TestCommand() {
|
||||
@ -10,7 +14,17 @@ public class TestCommand extends Command {
|
||||
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) {
|
||||
StringBuilder message = new StringBuilder("RoomUnit Statuses");
|
||||
|
||||
Set<Map.Entry<RoomUnitStatus, String>> statuses = gameClient.getHabbo().getRoomUnit().getStatuses().entrySet();
|
||||
|
||||
message.append("(").append(statuses.size()).append("):\r\n");
|
||||
|
||||
for(Map.Entry<RoomUnitStatus, String> status : statuses) {
|
||||
message.append(status.getKey().toString()).append("\r");
|
||||
}
|
||||
|
||||
gameClient.getHabbo().alert(new String[]{message.toString()});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -784,7 +784,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
habbo.getHabboStats().getChatCounter().decrementAndGet();
|
||||
}
|
||||
|
||||
if (this.cycleRoomUnit(habbo.getRoomUnit())) {
|
||||
habbo.getRoomUnit().cycle(this);
|
||||
|
||||
if(habbo.getRoomUnit().isStatusUpdateNeeded()) {
|
||||
habbo.getRoomUnit().setStatusUpdateNeeded(false);
|
||||
updatedUnit.add(habbo.getRoomUnit());
|
||||
}
|
||||
|
@ -381,12 +381,6 @@ public class RoomItemManager {
|
||||
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
THashSet<RoomTile> newOccupiedTiles = this.room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
|
||||
FurnitureMovementError fits = this.furnitureFitsAt(targetTile, item, rotation, true);
|
||||
|
||||
if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) {
|
||||
return fits;
|
||||
}
|
||||
|
||||
RoomItem topItem = this.getTopItemAt(occupiedTiles, null);
|
||||
|
||||
if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
|
||||
@ -652,21 +646,15 @@ public class RoomItemManager {
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(targetTile, baseItem.getWidth(), baseItem.getLength(), rotation);
|
||||
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
if (t.getState() == RoomTileState.INVALID) {
|
||||
for (RoomTile occupiedTile : occupiedTiles) {
|
||||
if (occupiedTile.getState() == RoomTileState.INVALID) {
|
||||
return FurnitureMovementError.INVALID_MOVE;
|
||||
}
|
||||
|
||||
if (!wiredPlaceUnder || (!item.isWalkable() && !baseItem.allowSit() && !baseItem.allowLay())) {
|
||||
if (checkForUnits) {
|
||||
if (this.room.getRoomUnitManager().hasHabbosAt(t)) {
|
||||
return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||
} else if (this.room.getRoomUnitManager().hasBotsAt(t)) {
|
||||
return FurnitureMovementError.TILE_HAS_BOTS;
|
||||
} else if (this.room.getRoomUnitManager().hasPetsAt(t)) {
|
||||
return FurnitureMovementError.TILE_HAS_PETS;
|
||||
}
|
||||
}
|
||||
if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) {
|
||||
if (checkForUnits && this.room.getRoomUnitManager().hasHabbosAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||
if (checkForUnits && this.room.getRoomUnitManager().hasBotsAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_BOTS;
|
||||
if (checkForUnits && this.room.getRoomUnitManager().hasPetsAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_PETS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,17 @@ public class RoomAvatar extends RoomUnit {
|
||||
this.removeStatus(RoomUnitStatus.SIGN);
|
||||
}
|
||||
|
||||
if(!this.isWalking() || this.getPath() == null || this.getPath().isEmpty()) {
|
||||
if (this.hasStatus(RoomUnitStatus.MOVE) && !this.isAnimateWalk()) {
|
||||
this.removeStatus(RoomUnitStatus.MOVE);
|
||||
}
|
||||
|
||||
if(!this.isWalking()) {
|
||||
RoomItem topItem = this.getRoom().getRoomItemManager().getTopItemAt(this.getCurrentPosition());
|
||||
return this.handleSitStatus(topItem) || this.handleLayStatus(topItem);
|
||||
}
|
||||
}
|
||||
|
||||
Habbo habboT = room.getRoomUnitManager().getHabboByRoomUnit(this);
|
||||
|
||||
if (!this.isWalking() && !this.isKicked() && this.removeStatus(RoomUnitStatus.MOVE) == null && habboT != null) {
|
||||
@ -263,7 +274,7 @@ public class RoomAvatar extends RoomUnit {
|
||||
}
|
||||
|
||||
if(habbo != null) {
|
||||
RoomItem topItem = room.getRoomItemManager().getTopItemAt(next.getX(), next.getY());
|
||||
RoomItem topItem = room.getRoomItemManager().getTopItemAt(next);
|
||||
|
||||
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");
|
||||
@ -333,28 +344,49 @@ public class RoomAvatar extends RoomUnit {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSitStatus(RoomItem topItem) {
|
||||
private boolean handleSitStatus(RoomItem topItem) {
|
||||
if(topItem == null || !topItem.getBaseItem().allowSit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this.isCmdSitEnabled()) {
|
||||
if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) {
|
||||
this.removeStatus(RoomUnitStatus.SIT);
|
||||
this.setStatusUpdateNeeded(true);
|
||||
} else if(this.getCurrentPosition().getState() == RoomTileState.SIT && (!this.hasStatus(RoomUnitStatus.SIT))) {
|
||||
if(this.getCurrentPosition().getState().equals(RoomTileState.SIT) && !this.hasStatus(RoomUnitStatus.SIT)) {
|
||||
this.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem)));
|
||||
this.setStatusUpdateNeeded(true);
|
||||
this.setCurrentZ(topItem.getZ());
|
||||
this.setRotation(RoomRotation.values()[topItem.getRotation()]);
|
||||
return true;
|
||||
} else if(!topItem.getBaseItem().allowSit() && this.hasStatus(RoomUnitStatus.SIT)) {
|
||||
this.removeStatus(RoomUnitStatus.SIT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleLayStatus(RoomItem topItem) {
|
||||
private boolean handleLayStatus(RoomItem topItem) {
|
||||
if(topItem == null || !topItem.getBaseItem().allowLay()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this.isCmdLayEnabled()) {
|
||||
if((topItem == null || !topItem.getBaseItem().allowLay()) && this.hasStatus(RoomUnitStatus.LAY)) {
|
||||
this.removeStatus(RoomUnitStatus.LAY);
|
||||
this.setStatusUpdateNeeded(true);
|
||||
} else if(!this.hasStatus(RoomUnitStatus.LAY)) {
|
||||
if(this.getCurrentPosition().getState().equals(RoomTileState.LAY) && !this.hasStatus(RoomUnitStatus.LAY)) {
|
||||
this.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem)));
|
||||
this.setStatusUpdateNeeded(true);
|
||||
this.setRotation(RoomRotation.values()[topItem.getRotation() % 4]);
|
||||
|
||||
if (topItem.getRotation() == 0 || topItem.getRotation() == 4) {
|
||||
this.setLocation(this.getRoom().getLayout().getTile(this.getCurrentPosition().getX(), topItem.getY()));
|
||||
} else {
|
||||
this.setLocation(this.getRoom().getLayout().getTile(topItem.getX(), this.getCurrentPosition().getY()));
|
||||
}
|
||||
return true;
|
||||
} else if (!topItem.getBaseItem().allowLay() && this.hasStatus(RoomUnitStatus.LAY)) {
|
||||
this.removeStatus(RoomUnitStatus.LAY);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user