More Refactoring

This commit is contained in:
Stankman 2023-07-20 16:17:29 -05:00
parent ab529344ef
commit 659a9d375f
80 changed files with 961 additions and 500 deletions

View File

@ -19,7 +19,7 @@ public class MimicCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 2) {
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]);
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_mimic.not_found"), ""), RoomChatMessageBubbles.ALERT);

View File

@ -17,7 +17,7 @@ public class PullCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length != 2) return true;
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]);
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT);

View File

@ -18,7 +18,7 @@ public class PushCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) {
if (params.length != 2) return true;
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]);
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_push.not_found"), params[1]), RoomChatMessageBubbles.ALERT);

View File

@ -15,7 +15,7 @@ public class SoftKickCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length != 2) return true;
final Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]);
final Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.keys.cmd_softkick_error"), params[1]), RoomChatMessageBubbles.ALERT);

View File

@ -20,7 +20,7 @@ public class SuperPullCommand extends Command {
return true;
}
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getHabbo(params[1]);
Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT);

View File

@ -35,7 +35,7 @@ public class FootballGame extends Game {
if (this.room == null || !this.room.isLoaded())
return;
Habbo habbo = this.room.getHabbo(kicker);
Habbo habbo = this.room.getRoomUnitManager().getHabboByRoomUnit(kicker);
if (habbo != null) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored"));
if (habbo.getHabboInfo().getId() != this.room.getRoomInfo().getOwnerInfo().getId()) {

View File

@ -36,7 +36,7 @@ public abstract class TagGame extends Game {
if (event.room == null || event.roomUnit == null || event.location == null) return;
if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentPosition(), event.location)) {
Habbo habbo = event.room.getHabbo(event.roomUnit);
Habbo habbo = event.room.getRoomUnitManager().getHabboByRoomUnit(event.roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getCurrentGame() != null) {

View File

@ -12,7 +12,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class Item implements ISerialize {
@Getter
private int id;
@Getter
@ -33,7 +32,7 @@ public class Item implements ISerialize {
private boolean allowWalk;
private boolean allowSit;
private boolean allowLay;
private boolean allowRecyle;
private boolean allowRecycle;
private boolean allowTrade;
private boolean allowMarketplace;
private boolean allowGift;
@ -52,7 +51,6 @@ public class Item implements ISerialize {
private String customParams;
@Getter
private String clothingOnWalk;
@Getter
private ItemInteraction interactionType;
@Getter
@ -103,7 +101,7 @@ public class Item implements ISerialize {
this.allowWalk = set.getBoolean("allow_walk");
this.allowSit = set.getBoolean("allow_sit");
this.allowLay = set.getBoolean("allow_lay");
this.allowRecyle = set.getBoolean("allow_recycle");
this.allowRecycle = set.getBoolean("allow_recycle");
this.allowTrade = set.getBoolean("allow_trade");
this.allowMarketplace = set.getBoolean("allow_marketplace_sell");
this.allowGift = set.getBoolean("allow_gift");
@ -164,7 +162,7 @@ public class Item implements ISerialize {
}
public boolean allowRecyle() {
return this.allowRecyle;
return this.allowRecycle;
}
public boolean allowTrade() {

View File

@ -21,7 +21,6 @@ import java.sql.SQLException;
@Slf4j
public class InteractionDefault extends RoomItem {
public InteractionDefault(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@ -110,7 +109,7 @@ public class InteractionDefault extends RoomItem {
}
if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) return;
@ -176,7 +175,7 @@ public class InteractionDefault extends RoomItem {
}
if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {

View File

@ -52,7 +52,7 @@ public class InteractionEffectTile extends InteractionPressurePlate {
super.onWalkOn(roomUnit, room, objects);
if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
this.giveEffect(room, roomUnit, habbo.getHabboInfo().getGender());

View File

@ -35,7 +35,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi
if (roomUnit == null)
return false;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasRight(Permission.ACC_GUILDGATE));
}

View File

@ -49,7 +49,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
this.roomUnitId = roomUnit.getVirtualId();
if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
this.startTime = Emulator.getIntUnixTimestamp();
@ -66,7 +66,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
this.reset(room);
if (roomUnit != null) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
RoomItem topItem = room.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY());
int nextEffectM = 0;
int nextEffectF = 0;
@ -107,7 +107,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
@Override
public void cycle(Room room) {
if (this.roomUnitId != -1) {
Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId);
Habbo habbo = room.getRoomUnitManager().getHabboByVirtualId(this.roomUnitId);
if (habbo != null) {
int timestamp = Emulator.getIntUnixTimestamp();

View File

@ -40,7 +40,7 @@ public class InteractionInformationTerminal extends InteractionCustomValues {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && this.values.containsKey("internalLink")) {
habbo.getClient().sendResponse(new InClientLinkMessageComposer(this.values.get("internalLink")));
}

View File

@ -110,7 +110,7 @@ public class InteractionMultiHeight extends RoomItem {
if (roomUnit != null
&& (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
&& roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
@ -132,7 +132,7 @@ public class InteractionMultiHeight extends RoomItem {
if (roomUnit != null
&& (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
&& roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {

View File

@ -94,7 +94,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
@ -123,7 +123,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);

View File

@ -77,7 +77,7 @@ public class InteractionRentableSpace extends RoomItem {
if (this.getExtradata().isEmpty())
return false;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null)
return true;

View File

@ -4,8 +4,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
@ -68,7 +68,7 @@ public class InteractionRoller extends RoomItem {
@Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
public boolean canStackAt(List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
if (NO_RULES) return true;
if (itemsAtLocation.isEmpty()) return false;

View File

@ -31,7 +31,7 @@ public class InteractionRoomClubGate extends InteractionDefault implements Condi
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return habbo != null && habbo.getHabboStats().hasActiveClub();
}
@ -69,7 +69,7 @@ public class InteractionRoomClubGate extends InteractionDefault implements Condi
if (roomUnit == null || room == null)
return;
room.getHabbo(roomUnit).getClient().sendResponse(
room.getRoomUnitManager().getHabboByRoomUnit(roomUnit).getClient().sendResponse(
new CustomUserNotificationMessageComposer(CustomUserNotificationMessageComposer.GATE_NO_HC)
);
}

View File

@ -20,7 +20,7 @@ public class InteractionRoomClubTeleportTile extends InteractionTeleportTile {
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
return habbo.getHabboStats().hasActiveClub();

View File

@ -30,7 +30,7 @@ public class InteractionTeleportTile extends InteractionTeleport {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
if (roomUnit != null && this.canWalkOn(roomUnit, room, objects)) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (!canUseTeleport(habbo.getClient(), room))

View File

@ -22,9 +22,9 @@ public class InteractionTrap extends InteractionDefault {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
if (this.getExtradata().equals("0") || roomUnit == null || room.getHabbo(roomUnit) == null) return;
if (this.getExtradata().equals("0") || roomUnit == null || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) return;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId();
roomUnit.stopWalking();
super.onWalkOn(roomUnit, room, objects);

View File

@ -118,7 +118,7 @@ public class InteractionWater extends InteractionDefault {
}
@Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
public boolean canStackAt(List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
for (Pair<RoomTile, THashSet<RoomItem>> set : itemsAtLocation) {
for (RoomItem item : set.getValue()) {
if(item != this)
@ -126,7 +126,7 @@ public class InteractionWater extends InteractionDefault {
}
}
return super.canStackAt(room, itemsAtLocation);
return super.canStackAt(itemsAtLocation);
}
@Override

View File

@ -5,11 +5,13 @@ import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionPushable;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -149,7 +151,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
@Override
public void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
Habbo habbo = room.getHabbo(kicker);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(kicker);
if (habbo != null) {
BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);

View File

@ -5,9 +5,9 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
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.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
@ -62,7 +62,7 @@ public class InteractionBattleBanzaiTile extends RoomItem {
if (state % 3 == 2)
return;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null)
return;
@ -92,12 +92,12 @@ public class InteractionBattleBanzaiTile extends RoomItem {
}
@Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
public boolean canStackAt(List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
for (Pair<RoomTile, THashSet<RoomItem>> set : itemsAtLocation) {
if (set.getValue() != null && !set.getValue().isEmpty()) return false;
}
return super.canStackAt(room, itemsAtLocation);
return super.canStackAt(itemsAtLocation);
}
@Override

View File

@ -54,12 +54,12 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
room.addGame(game);
}
GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit));
GameTeam team = game.getTeamForHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
if (team != null) {
game.removeHabbo(room.getHabbo(roomUnit));
game.removeHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
} else {
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
game.addHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit), this.teamColor);
}
updateState(game, 5);

View File

@ -113,7 +113,7 @@ public class InteractionFootballGate extends RoomItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboStats().getCache().containsKey(CACHE_KEY)) {
String oldlook = (String) habbo.getHabboStats().getCache().get(CACHE_KEY);

View File

@ -8,9 +8,9 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
@ -91,7 +91,7 @@ public class InteractionFreezeBlock extends RoomItem {
if (game == null || !game.state.equals(GameState.RUNNING))
return;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null || habbo.getHabboInfo().getCurrentGame() != FreezeGame.class)
return;

View File

@ -74,11 +74,11 @@ public class InteractionFreezeTile extends RoomItem {
@Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
public boolean canStackAt(List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
for (Pair<RoomTile, THashSet<RoomItem>> set : itemsAtLocation) {
if (set.getValue() != null && !set.getValue().isEmpty()) return false;
}
return super.canStackAt(room, itemsAtLocation);
return super.canStackAt(itemsAtLocation);
}
}

View File

@ -52,12 +52,12 @@ public class InteractionFreezeGate extends InteractionGameGate {
room.addGame(game);
}
GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit));
GameTeam team = game.getTeamForHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
if (team != null) {
game.removeHabbo(room.getHabbo(roomUnit));
game.removeHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
} else {
game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
game.addHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit), this.teamColor);
}
updateState(game, 5);

View File

@ -4,9 +4,9 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.tag.TagGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
@ -29,7 +29,7 @@ public abstract class InteractionTagField extends RoomItem {
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
return habbo.getHabboInfo().getCurrentGame() == null || habbo.getHabboInfo().getCurrentGame() == this.gameClazz;
@ -50,7 +50,7 @@ public abstract class InteractionTagField extends RoomItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getCurrentGame() == null) {

View File

@ -28,7 +28,7 @@ public class InteractionIceTagField extends InteractionTagField {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null)
this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp());
}
@ -37,7 +37,7 @@ public class InteractionIceTagField extends InteractionTagField {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && this.stepTimes.containsKey(habbo)) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60);
this.stepTimes.remove(habbo);

View File

@ -28,7 +28,7 @@ public class InteractionRollerskateField extends InteractionTagField {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null)
this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp());
}
@ -37,7 +37,7 @@ public class InteractionRollerskateField extends InteractionTagField {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && this.stepTimes.containsKey(habbo)) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60);
this.stepTimes.remove(habbo);

View File

@ -25,7 +25,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition {
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return habbo != null && habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId());
}

View File

@ -24,7 +24,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition {
if (room.getRoomInfo().getGuild().getId() == 0)
return false;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return habbo == null || !habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId());
}

View File

@ -33,7 +33,7 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
GameTeamColors teamColor = GameTeamColors.values()[teamValue];
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(teamColor);

View File

@ -27,7 +27,7 @@ public class WiredConditionRoomWearsBadge extends InteractionWiredCondition {
}
String badgeCode = this.getWiredSettings().getStringParam();
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if(habbo == null) {
return false;

View File

@ -33,7 +33,7 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
GameTeamColors teamColor = GameTeamColors.values()[teamValue];
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getGamePlayer() != null) {

View File

@ -20,7 +20,7 @@ public class WiredEffectAlert extends WiredEffectWhisper {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
habbo.alert(this.getWiredSettings().getStringParam()

View File

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

View File

@ -36,7 +36,7 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
return false;
}
Habbo habbo = room.getHabbo(roomAvatar);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
List<Bot> bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam());
int itemId = this.getWiredSettings().getIntegerParams().get(PARAM_ITEM_ID);

View File

@ -33,7 +33,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
String message = stringParams[1].substring(0, Math.min(stringParams[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())

View File

@ -33,7 +33,7 @@ public class WiredEffectBotTalkToRoom extends InteractionWiredEffect {
String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
String message = stringParams[1].substring(0, Math.min(stringParams[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())

View File

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

View File

@ -27,7 +27,7 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper {
try {
int itemId = Integer.parseInt(this.getWiredSettings().getStringParam());
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
habbo.getRoomUnit().setHandItem(itemId);

View File

@ -33,7 +33,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends WiredEffectWhisper
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
return false;

View File

@ -34,7 +34,7 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect {
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
return false;

View File

@ -39,7 +39,7 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
return false;

View File

@ -61,7 +61,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return habbo != null && WiredHandler.getReward(habbo, this);
}

View File

@ -42,7 +42,7 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && habbo.getHabboInfo().getCurrentGame() != null) {
Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());

View File

@ -35,7 +35,7 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
GameTeamColors teamColor = GameTeamColors.values()[teamValue];
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
WiredGame game = (WiredGame) room.getGameOrCreate(WiredGame.class);

View File

@ -30,7 +30,7 @@ public class WiredEffectKickRoom extends InteractionWiredEffect {
if (room == null)
return false;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.hasRight(Permission.ACC_UNKICKABLE)) {

View File

@ -23,7 +23,7 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getCurrentGame() != null) {

View File

@ -33,7 +33,7 @@ public class WiredEffectMuteRoom extends InteractionWiredEffect {
if (roomUnit == null)
return true;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (room.hasRights(habbo))

View File

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

View File

@ -14,9 +14,9 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
import com.eu.habbo.habbohotel.items.interactions.pets.*;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import lombok.extern.slf4j.Slf4j;
@ -83,7 +83,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
return false;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
for (RoomItem item : this.getWiredSettings().getItems(room)) {

View File

@ -32,7 +32,7 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
}
if (roomUnit != null) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
String msg = this.getWiredSettings().getStringParam().replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + "");

View File

@ -59,7 +59,7 @@ public class WiredBlob extends InteractionDefault {
if (!this.getExtradata().equals(WiredBlobState.ACTIVE.getState())) return;
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
GamePlayer player = habbo.getHabboInfo().getGamePlayer();

View File

@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -22,7 +22,7 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
if(stuff.length == 0 || room.getHabbo(roomUnit) == null) {
if(stuff.length == 0 || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) {
return false;
}

View File

@ -25,7 +25,7 @@ public class WiredTriggerRoomEntersRoom extends InteractionWiredTrigger {
return true;
}
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
return habbo.getHabboInfo().getUsername().equalsIgnoreCase(this.getWiredSettings().getStringParam());

View File

@ -31,7 +31,7 @@ public class WiredTriggerRoomSaysKeyword extends InteractionWiredTrigger {
if (stuff[0] instanceof String) {
if (((String) stuff[0]).toLowerCase().contains(this.getWiredSettings().getStringParam().toLowerCase())) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return !ownerOnly || (habbo != null && room.getRoomInfo().getOwnerInfo().getId() == habbo.getHabboInfo().getId());
}
}

View File

@ -70,6 +70,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
import io.netty.util.internal.ConcurrentSet;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.math3.util.Pair;
@ -95,6 +96,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private final RoomUnitManager roomUnitManager;
@Getter
private final RoomItemManager roomItemManager;
@Getter
private TraxManager traxManager;
private static final String CAUGHT_EXCEPTION = "Caught exception";
public static final Comparator<Room> SORT_SCORE = (o1, o2) -> o2.roomInfo.getScore() - o1.roomInfo.getScore();
@ -114,14 +116,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public static final double MAXIMUM_FURNI_HEIGHT = 40d;
public final ConcurrentHashMap<RoomTile, THashSet<RoomItem>> tileCache = new ConcurrentHashMap<>();
public final List<Integer> userVotes;
@Getter
private final TIntObjectMap<Habbo> habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
private final THashSet<RoomTrade> activeTrades;
@Getter
private final TIntArrayList rights;
private final TIntIntHashMap mutedHabbos;
private final TIntObjectHashMap<RoomBan> bannedHabbos;
@Getter
private final ConcurrentSet<Game> games;
@Getter
private final TIntObjectMap<String> furniOwnerNames;
private final TIntIntMap furniOwnerCount;
@Getter
private final THashSet<String> wordFilterWords;
private final TIntObjectMap<RoomItem> roomItems;
private final Object loadLock = new Object();
@ -130,33 +137,53 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public volatile boolean preventUncaching = false;
public final ConcurrentHashMap.KeySetView<ServerMessage, Boolean> scheduledComposers = ConcurrentHashMap.newKeySet();
public ConcurrentHashMap.KeySetView<Runnable, Boolean> scheduledTasks = ConcurrentHashMap.newKeySet();
@Getter
private String wordQuiz = "";
@Getter
private int noVotes = 0;
@Getter
private int yesVotes = 0;
@Getter
private int wordQuizEnd = 0;
public ScheduledFuture<?> roomCycleTask;
@Getter
@Setter
private RoomLayout layout;
private final String layoutName;
@Getter
@Setter
private volatile boolean allowBotsWalk;
@Setter
private volatile boolean allowEffects;
@Getter
private RoomPromotion promotion;
@Setter
private volatile boolean needsUpdate;
@Getter
private volatile boolean loaded;
@Getter
private volatile boolean preLoaded;
private int roomIdleCycles;
private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30);
private long rollerCycle = System.currentTimeMillis();
@Getter
@Setter
private volatile int lastTimerReset = Emulator.getIntUnixTimestamp();
@Getter
@Setter
private volatile boolean muted;
@Getter
private RoomSpecialTypes roomSpecialTypes;
private boolean cycleOdd;
@Getter
private long cycleTimestamp;
@Getter
final HashMap<RoomTile, InteractionWiredTrigger> triggersOnRoom;
public Room(ResultSet set) throws SQLException {
this.roomInfo = new RoomInfo(set);
this.roomUnitManager = new RoomUnitManager(this.roomInfo.getId());
this.roomItemManager = new RoomItemManager();
this.roomUnitManager = new RoomUnitManager(this);
this.roomItemManager = new RoomItemManager(this);
this.layoutName = set.getString("model");
this.bannedHabbos = new TIntObjectHashMap<>();
@ -212,7 +239,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.loadLayout();
this.loadRights(connection);
//TODO Deprecated
this.loadItems(connection);
this.roomItemManager.load(connection);
this.loadHeightmap();
this.roomUnitManager.load(connection);
this.loadWordFilter(connection);
@ -408,7 +439,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return;
}
this.removeHabboItem(item.getId());
this.removeHabboItem(item);
item.onPickUp(this);
item.setRoomId(0);
item.needsUpdate(true);
@ -521,6 +552,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
public void updateBotsAt(RoomTile tile) {
this.updateBotsAt(tile.getX(), tile.getY());
}
public void updateBotsAt(short x, short y) {
RoomItem topItem = this.getTopItemAt(x, y);
@ -1090,7 +1125,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
double newZ = unit.getCurrentZ() + zOffset;
if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.HABBO) {
roomUserRolledEvent = new UserRolledEvent(getHabbo(unit), roller, tileInFront);
roomUserRolledEvent = new UserRolledEvent(this.getRoomUnitManager().getHabboByRoomUnit(unit), roller, tileInFront);
Emulator.getPluginManager().fireEvent(roomUserRolledEvent);
if (roomUserRolledEvent.isCancelled())
@ -1100,7 +1135,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
// horse riding
boolean isRiding = false;
if (unit.getRoomUnitType() == RoomUnitType.HABBO) {
Habbo rollingHabbo = this.getHabbo(unit);
Habbo rollingHabbo = this.getRoomUnitManager().getHabboByRoomUnit(unit);
if (rollingHabbo != null && rollingHabbo.getHabboInfo() != null) {
RideablePet riding = rollingHabbo.getHabboInfo().getRiding();
if (riding != null) {
@ -1617,10 +1652,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return item;
}
void removeHabboItem(int id) {
this.removeHabboItem(this.getHabboItem(id));
}
public void removeHabboItem(RoomItem item) {
if (item != null) {
@ -1788,18 +1819,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.teleportRoomUnitToLocation(habbo.getRoomUnit(), item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item));
}
public void teleportHabboToLocation(Habbo habbo, short x, short y) {
this.teleportRoomUnitToLocation(habbo.getRoomUnit(), x, y, 0.0);
}
public void teleportRoomUnitToItem(RoomUnit roomUnit, RoomItem item) {
this.teleportRoomUnitToLocation(roomUnit, item.getX(), item.getY(), item.getZ() + Item.getCurrentHeight(item));
}
public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y) {
this.teleportRoomUnitToLocation(roomUnit, x, y, 0.0);
}
public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) {
if (this.loaded) {
RoomTile tile = this.layout.getTile(x, y);
@ -2561,31 +2580,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return null;
}
public Habbo getHabbo(String username) {
for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) {
if (habbo.getHabboInfo().getUsername().equalsIgnoreCase(username))
return habbo;
}
return null;
}
public Habbo getHabbo(RoomUnit roomUnit) {
for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) {
if (habbo.getRoomUnit() == roomUnit)
return habbo;
}
return null;
}
public Habbo getHabboByRoomUnitId(int roomUnitId) {
for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) {
if (habbo.getRoomUnit().getVirtualId() == roomUnitId)
return habbo;
}
return null;
}
public void sendComposer(ServerMessage message) {
for (Habbo habbo : this.roomUnitManager.getRoomHabbos()) {
if (habbo.getClient() == null) continue;
@ -3207,6 +3201,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return FurnitureMovementError.MAX_ITEMS;
}
if (item instanceof InteractionMoodLight && !this.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) {
return FurnitureMovementError.MAX_DIMMERS;
}
if (item instanceof InteractionJukeBox && !this.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) {
return FurnitureMovementError.MAX_SOUNDFURNI;
}
if (tile == null || tile.getState() == RoomTileState.INVALID) {
return FurnitureMovementError.INVALID_MOVE;
}
@ -3280,7 +3281,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
if (!item.canStackAt(this, tileFurniList)) {
if (!item.canStackAt(tileFurniList)) {
return FurnitureMovementError.CANT_STACK;
}
@ -3288,6 +3289,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public FurnitureMovementError placeFloorFurniAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) {
FurnitureMovementError error = this.canPlaceFurnitureAt(item, owner, tile, rotation);
if(!error.equals(FurnitureMovementError.NONE)) {
return error;
}
boolean pluginHelper = false;
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile));
@ -3301,7 +3308,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
FurnitureMovementError fits = furnitureFitsAt(tile, item, rotation);
FurnitureMovementError fits = this.furnitureFitsAt(tile, item, rotation);
if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) {
return fits;
@ -3430,7 +3437,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
}
if (!magicTile && !item.canStackAt(this, tileFurniList)) {
if (!magicTile && !item.canStackAt(tileFurniList)) {
return FurnitureMovementError.CANT_STACK;
}
}
@ -3542,144 +3549,4 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
return FurnitureMovementError.NONE;
}
public FurnitureMovementError slideFurniTo(RoomItem item, RoomTile tile, int rotation) {
boolean magicTile = item instanceof InteractionStackHelper;
//Check if can be placed at new position
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
for (RoomTile t : occupiedTiles) {
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
}
if (!magicTile && !item.canStackAt(this, tileFurniList)) {
return FurnitureMovementError.CANT_STACK;
}
item.setRotation(rotation);
//Place at new position
if (magicTile) {
item.setZ(tile.getZ());
item.setExtradata("" + item.getZ() * 100);
}
if (item.getZ() > MAXIMUM_FURNI_HEIGHT) {
item.setZ(MAXIMUM_FURNI_HEIGHT);
}
double offset = this.getStackHeight(tile.getX(), tile.getY(), false, item) - item.getZ();
this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, offset, this).compose());
//Update Habbos at old position
for (RoomTile t : occupiedTiles) {
this.updateHabbosAt(t);
this.updateBotsAt(t.getX(), t.getY());
}
return FurnitureMovementError.NONE;
}
public TIntObjectMap<Habbo> getHabboQueue() {
return this.habboQueue;
}
public TIntArrayList getRights() {
return this.rights;
}
public ConcurrentSet<Game> getGames() {
return this.games;
}
public TIntObjectMap<String> getFurniOwnerNames() {
return this.furniOwnerNames;
}
public THashSet<String> getWordFilterWords() {
return this.wordFilterWords;
}
public String getWordQuiz() {
return this.wordQuiz;
}
public int getNoVotes() {
return this.noVotes;
}
public int getYesVotes() {
return this.yesVotes;
}
public int getWordQuizEnd() {
return this.wordQuizEnd;
}
public RoomLayout getLayout() {
return this.layout;
}
public boolean isAllowBotsWalk() {
return this.allowBotsWalk;
}
public RoomPromotion getPromotion() {
return this.promotion;
}
public boolean isLoaded() {
return this.loaded;
}
public boolean isPreLoaded() {
return this.preLoaded;
}
public int getLastTimerReset() {
return this.lastTimerReset;
}
public boolean isMuted() {
return this.muted;
}
public RoomSpecialTypes getRoomSpecialTypes() {
return this.roomSpecialTypes;
}
public TraxManager getTraxManager() {
return this.traxManager;
}
public long getCycleTimestamp() {
return this.cycleTimestamp;
}
public HashMap<RoomTile, InteractionWiredTrigger> getTriggersOnRoom() {
return this.triggersOnRoom;
}
public void setLayout(RoomLayout layout) {
this.layout = layout;
}
public void setAllowBotsWalk(boolean allowBotsWalk) {
this.allowBotsWalk = allowBotsWalk;
}
public void setAllowEffects(boolean allowEffects) {
this.allowEffects = allowEffects;
}
public void setNeedsUpdate(boolean needsUpdate) {
this.needsUpdate = needsUpdate;
}
public void setLastTimerReset(int lastTimerReset) {
this.lastTimerReset = lastTimerReset;
}
public void setMuted(boolean muted) {
this.muted = muted;
}
}

View File

@ -49,7 +49,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable {
public RoomChatMessage(MessageHandler message) {
if (message.packet.getMessageId() == Incoming.whisperEvent) {
String data = message.packet.readString();
this.targetHabbo = message.client.getHabbo().getRoomUnit().getRoom().getHabbo(data.split(" ")[0]);
this.targetHabbo = message.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(data.split(" ")[0]);
this.message = data.substring(data.split(" ")[0].length() + 1);
} else {
this.message = message.packet.readString();

View File

@ -1,37 +1,58 @@
package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.FurnitureType;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.interactions.*;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest;
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink;
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood;
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetToy;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
import com.eu.habbo.habbohotel.items.interactions.pets.*;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.items.types.RoomFloorItem;
import com.eu.habbo.habbohotel.rooms.entities.items.types.RoomWallItem;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.ItemRemoveMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.furniture.FurnitureBuildheightEvent;
import com.eu.habbo.plugin.events.furniture.FurniturePickedUpEvent;
import com.eu.habbo.plugin.events.furniture.FurniturePlacedEvent;
import gnu.trove.set.hash.THashSet;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.math3.util.Pair;
import java.util.HashMap;
import java.util.HashSet;
import java.awt.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
@Slf4j
@Getter
public class RoomItemManager {
private final Room room;
private final RoomWiredManager wiredManager;
private final ConcurrentHashMap<Integer, RoomItem> currentItems;
private final HashMap<Integer, RoomFloorItem> floorItems;
private final HashMap<Integer, RoomWallItem> wallItems;
private final ConcurrentHashMap<Integer, RoomItem> floorItems;
private final ConcurrentHashMap<Integer, RoomItem> wallItems;
private final HashSet<ICycleable> cycleTasks;
private final HashMap<WiredTriggerType, List<InteractionWiredTrigger>> wiredTriggers;
private final HashMap<WiredEffectType, List<InteractionWiredEffect>> wiredEffects;
private final HashMap<WiredConditionType, List<InteractionWiredCondition>> wiredConditions;
private final HashMap<Integer, InteractionWiredExtra> wiredExtras;
private final HashMap<Integer, InteractionNest> nests;
private final HashMap<Integer, InteractionPetDrink> petDrinks;
private final HashMap<Integer, InteractionPetFood> petFoods;
@ -42,19 +63,18 @@ public class RoomItemManager {
private final HashMap<Integer, InteractionGameTimer> gameTimers;
private final HashMap<Integer, InteractionBattleBanzaiTeleporter> banzaiTeleporters;
private final HashMap<Integer, InteractionFreezeExitTile> freezeExitTile;
public RoomItemManager() {
this.currentItems = new ConcurrentHashMap<>();
private final HashMap<Integer, RoomItem> undefinedSpecials;
this.floorItems = new HashMap<>();
this.wallItems = new HashMap<>();
public RoomItemManager(Room room) {
this.room = room;
this.currentItems = new ConcurrentHashMap<>();
this.wiredManager = new RoomWiredManager();
this.floorItems = new ConcurrentHashMap<>();
this.wallItems = new ConcurrentHashMap<>();
this.cycleTasks = new HashSet<>(0);
this.wiredTriggers = new HashMap<>(0);
this.wiredEffects = new HashMap<>(0);
this.wiredConditions = new HashMap<>(0);
this.wiredExtras = new HashMap<>(0);
this.nests = new HashMap<>(0);
this.petDrinks = new HashMap<>(0);
this.petFoods = new HashMap<>(0);
@ -68,5 +88,531 @@ public class RoomItemManager {
this.banzaiTeleporters = new HashMap<>(0);
this.freezeExitTile = new HashMap<>(0);
this.undefinedSpecials = new HashMap<>(0);
}
public synchronized void load(Connection connection) {
this.loadItems(connection);
}
private synchronized void loadItems(Connection connection) {
this.currentItems.clear();
this.wiredManager.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) {
statement.setInt(1, this.room.getRoomInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set);
if (item != null) {
this.addRoomItem(item);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error("Caught Exception", e);
}
}
public void addRoomItem(RoomItem item) {
if (this.currentItems.size() > Room.MAXIMUM_FURNI) {
log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.room.getRoomInfo().getId(), this.currentItems.size(), Room.MAXIMUM_FURNI);
}
synchronized (this.currentItems) {
try {
this.currentItems.put(item.getId(), item);
this.sortItem(item);
item.setRoomId(this.room.getRoomInfo().getId());
} catch (Exception ignored) {
}
}
}
public void removeHabboItem(RoomItem item) {
if (item != null) {
RoomItem i;
synchronized (this.currentItems) {
i = this.currentItems.remove(item.getId());
}
if (i != null) {
if (item instanceof ICycleable) {
this.removeCycleTask((ICycleable) item);
}
if (item instanceof InteractionWired wired) {
this.wiredManager.removeWired(wired);
} else if (item instanceof InteractionBattleBanzaiTeleporter) {
this.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item);
} else if (item instanceof InteractionRoller) {
this.removeRoller((InteractionRoller) item);
} else if (item instanceof InteractionGameScoreboard) {
this.removeScoreboard((InteractionGameScoreboard) item);
} else if (item instanceof InteractionGameGate) {
this.removeGameGate((InteractionGameGate) item);
} else if (item instanceof InteractionGameTimer) {
this.removeGameTimer((InteractionGameTimer) item);
} else if (item instanceof InteractionFreezeExitTile) {
this.removeFreezeExitTile((InteractionFreezeExitTile) item);
} else if (item instanceof InteractionNest) {
this.removeNest((InteractionNest) item);
} else if (item instanceof InteractionPetDrink) {
this.removePetDrink((InteractionPetDrink) item);
} else if (item instanceof InteractionPetFood) {
this.removePetFood((InteractionPetFood) item);
} else if (item instanceof InteractionPetToy) {
this.removePetToy((InteractionPetToy) item);
} else if (item instanceof InteractionPetTree) {
this.removeUndefined(item);
} else if (item instanceof InteractionPetTrampoline) {
this.removeUndefined(item);
} else if (item instanceof InteractionMoodLight) {
this.removeUndefined(item);
} else if (item instanceof InteractionPyramid) {
this.removeUndefined(item);
} else if (item instanceof InteractionMusicDisc) {
this.removeUndefined(item);
} else if (item instanceof InteractionBattleBanzaiSphere) {
this.removeUndefined(item);
} else if (item instanceof InteractionTalkingFurniture) {
this.removeUndefined(item);
} else if (item instanceof InteractionWaterItem) {
this.removeUndefined(item);
} else if (item instanceof InteractionWater) {
this.removeUndefined(item);
} else if (item instanceof InteractionMuteArea) {
this.removeUndefined(item);
} else if (item instanceof InteractionTagPole) {
this.removeUndefined(item);
} else if (item instanceof InteractionTagField) {
this.removeUndefined(item);
} else if (item instanceof InteractionJukeBox) {
this.removeUndefined(item);
} else if (item instanceof InteractionPetBreedingNest) {
this.removeUndefined(item);
} else if (item instanceof InteractionBlackHole) {
this.removeUndefined(item);
} else if (item instanceof InteractionWiredHighscore) {
this.removeUndefined(item);
} else if (item instanceof InteractionStickyPole) {
this.removeUndefined(item);
} else if (item instanceof WiredBlob) {
this.removeUndefined(item);
} else if (item instanceof InteractionTent) {
this.removeUndefined(item);
} else if (item instanceof InteractionSnowboardSlope) {
this.removeUndefined(item);
} else if (item instanceof InteractionBuildArea) {
this.removeUndefined(item);
}
}
}
}
public HashSet<RoomItem> getItemsOfType(Class<? extends RoomItem> type) {
return this.currentItems.values().stream()
.filter(item -> type.equals(item.getClass()))
.collect(Collectors.toCollection(HashSet::new));
}
public FurnitureMovementError canPlaceFurnitureAt(RoomItem item, Habbo habbo, RoomTile tile, int rotation) {
if (this.currentItems.size() >= Room.MAXIMUM_FURNI) {
return FurnitureMovementError.MAX_ITEMS;
}
if (item instanceof InteractionMoodLight && !this.getItemsOfType(InteractionMoodLight.class).isEmpty()) {
return FurnitureMovementError.MAX_DIMMERS;
}
if (item instanceof InteractionJukeBox && !this.getItemsOfType(InteractionJukeBox.class).isEmpty()) {
return FurnitureMovementError.MAX_SOUNDFURNI;
}
if (tile == null || tile.getState() == RoomTileState.INVALID) {
return FurnitureMovementError.INVALID_MOVE;
}
rotation %= 8;
if (this.room.hasRights(habbo) || this.room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) {
return FurnitureMovementError.NONE;
}
if (habbo.getHabboStats().isRentingSpace()) {
RoomItem rentSpace = this.currentItems.get(habbo.getHabboStats().getRentedItemId());
if (rentSpace != null) {
if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(tile.getX(), tile.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) {
return FurnitureMovementError.NO_RIGHTS;
} else {
return FurnitureMovementError.NONE;
}
}
}
for (RoomItem area : this.getItemsOfType(InteractionBuildArea.class)) {
if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) {
return FurnitureMovementError.NONE;
}
}
return FurnitureMovementError.NO_RIGHTS;
}
public FurnitureMovementError placeFloorItemAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) {
boolean pluginHelper = false;
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile));
if (event.isCancelled()) {
return FurnitureMovementError.CANCEL_PLUGIN_PLACE;
}
pluginHelper = event.hasPluginHelper();
}
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
FurnitureMovementError fits = this.furnitureFitsAt(item, tile, rotation);
if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) {
return fits;
}
double height = tile.getStackHeight();
for (RoomTile tile2 : occupiedTiles) {
double sHeight = tile2.getStackHeight();
if (sHeight > height) {
height = sHeight;
}
}
if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) {
FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height));
if (event.hasChangedHeight()) {
height = event.getUpdatedHeight();
}
}
item.setZ(height);
item.setX(tile.getX());
item.setY(tile.getY());
item.setRotation(rotation);
item.needsUpdate(true);
this.addRoomItem(item);
item.onPlace(this.room);
this.room.updateTiles(occupiedTiles);
this.room.sendComposer(new ObjectAddMessageComposer(item, this.room.getFurniOwnerName(item.getUserId())).compose());
for (RoomTile t : occupiedTiles) {
this.room.updateHabbosAt(t);
this.room.updateBotsAt(t);
}
Emulator.getThreading().run(item);
return FurnitureMovementError.NONE;
}
public void pickUpItem(RoomItem item, Habbo picker) {
if (item == null)
return;
if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) {
Event furniturePickedUpEvent = new FurniturePickedUpEvent(item, picker);
Emulator.getPluginManager().fireEvent(furniturePickedUpEvent);
if (furniturePickedUpEvent.isCancelled())
return;
}
this.removeHabboItem(item);
item.onPickUp(this.room);
item.setRoomId(0);
item.needsUpdate(true);
if (item.getBaseItem().getType() == FurnitureType.FLOOR) {
this.room.sendComposer(new RemoveFloorItemComposer(item).compose());
THashSet<RoomTile> updatedTiles = new THashSet<>();
Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) {
for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) {
double stackHeight = this.room.getStackHeight(x, y, false);
RoomTile tile = this.room.getLayout().getTile(x, y);
if (tile != null) {
tile.setStackHeight(stackHeight);
updatedTiles.add(tile);
}
}
}
this.room.sendComposer(new HeightMapUpdateMessageComposer(this.room, updatedTiles).compose());
this.room.updateTiles(updatedTiles);
updatedTiles.forEach(tile -> {
this.room.updateHabbosAt(tile);
this.room.updateBotsAt(tile.getX(), tile.getY());
});
} else if (item.getBaseItem().getType() == FurnitureType.WALL) {
this.room.sendComposer(new ItemRemoveMessageComposer(item).compose());
}
Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker : Emulator.getGameServer().getGameClientManager().getHabbo(item.getUserId()));
if (habbo != null) {
habbo.getInventory().getItemsComponent().addItem(item);
habbo.getClient().sendResponse(new UnseenItemsComposer(item));
habbo.getClient().sendResponse(new FurniListInvalidateComposer());
}
Emulator.getThreading().run(item);
}
public FurnitureMovementError furnitureFitsAt(RoomItem item, RoomTile tile, int rotation) {
return furnitureFitsAt(item, tile, rotation, true);
}
public FurnitureMovementError furnitureFitsAt(RoomItem item, RoomTile tile, int rotation, boolean checkForUnits) {
if (!this.room.getLayout().fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
return FurnitureMovementError.INVALID_MOVE;
if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
for (RoomTile t : occupiedTiles) {
if (t.getState() == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE;
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) {
if (this.room.getRoomUnitManager().hasHabbosAt(t)) return FurnitureMovementError.TILE_HAS_HABBOS;
}
if (checkForUnits) {
if (!this.room.getRoomUnitManager().getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS;
}
if (checkForUnits) {
if (this.room.getRoomUnitManager().hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS;
}
}
}
Optional<RoomItem> stackHelper = this.room.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny();
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
for (RoomTile t : occupiedTiles) {
tileFurniList.add(Pair.create(t, this.room.getItemsAt(t)));
RoomItem topItem = this.room.getTopItemAt(t.getX(), t.getY(), item);
if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
return FurnitureMovementError.CANT_STACK;
}
if ((stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) || topItem != null && (topItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() == InteractionWater.class || item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class))) {
return FurnitureMovementError.CANT_STACK;
}
}
if (!item.canStackAt(tileFurniList)) {
return FurnitureMovementError.CANT_STACK;
}
return FurnitureMovementError.NONE;
}
public void addCycleTask(ICycleable task) {
this.cycleTasks.add(task);
}
public void removeCycleTask(ICycleable task) {
this.cycleTasks.remove(task);
}
public void addBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) {
this.banzaiTeleporters.put(item.getId(), item);
}
public void removeBanzaiTeleporter(InteractionBattleBanzaiTeleporter item) {
this.banzaiTeleporters.remove(item.getId());
}
public void addRoller(InteractionRoller item) {
synchronized (this.rollers) {
this.rollers.put(item.getId(), item);
}
}
public void removeRoller(InteractionRoller roller) {
synchronized (this.rollers) {
this.rollers.remove(roller.getId());
}
}
public void addGameScoreboard(InteractionGameScoreboard scoreboard) {
this.gameScoreboards.put(scoreboard.getId(), scoreboard);
}
public void removeScoreboard(InteractionGameScoreboard scoreboard) {
this.gameScoreboards.remove(scoreboard.getId());
}
public void addGameGate(InteractionGameGate gameGate) {
this.gameGates.put(gameGate.getId(), gameGate);
}
public void removeGameGate(InteractionGameGate gameGate) {
this.gameGates.remove(gameGate.getId());
}
public void addGameTimer(InteractionGameTimer gameTimer) {
this.gameTimers.put(gameTimer.getId(), gameTimer);
}
public void removeGameTimer(InteractionGameTimer gameTimer) {
this.gameTimers.remove(gameTimer.getId());
}
public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) {
this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile);
}
public void removeFreezeExitTile(InteractionFreezeExitTile freezeExitTile) {
this.freezeExitTile.remove(freezeExitTile.getId());
}
public void addNest(InteractionNest item) {
this.nests.put(item.getId(), item);
}
public void removeNest(InteractionNest item) {
this.nests.remove(item.getId());
}
public void addPetDrink(InteractionPetDrink item) {
this.petDrinks.put(item.getId(), item);
}
public void removePetDrink(InteractionPetDrink item) {
this.petDrinks.remove(item.getId());
}
public void addPetFood(InteractionPetFood item) {
this.petFoods.put(item.getId(), item);
}
public void removePetFood(InteractionPetFood petFood) {
this.petFoods.remove(petFood.getId());
}
public InteractionPetToy getPetToy(int itemId) {
return this.petToys.get(itemId);
}
public void addPetToy(InteractionPetToy item) {
this.petToys.put(item.getId(), item);
}
public void removePetToy(InteractionPetToy petToy) {
this.petToys.remove(petToy.getId());
}
public void addUndefined(RoomItem item) {
synchronized (this.undefinedSpecials) {
this.undefinedSpecials.put(item.getId(), item);
}
}
public void removeUndefined(RoomItem item) {
synchronized (this.undefinedSpecials) {
this.undefinedSpecials.remove(item.getId());
}
}
private void sortItem(RoomItem item) {
if(item.getBaseItem().getType().equals(FurnitureType.FLOOR)) {
this.floorItems.put(item.getId(), item);
this.sortFloorItem(item);
} else if(item.getBaseItem().getType().equals(FurnitureType.WALL)) {
this.wallItems.put(item.getId(), item);
}
}
private void sortFloorItem(RoomItem item) {
if (item instanceof ICycleable) {
this.addCycleTask((ICycleable) item);
}
if(item instanceof InteractionWired wired) {
this.wiredManager.addWired(wired);
} else if (item instanceof InteractionBattleBanzaiTeleporter interactionBattleBanzaiTeleporter) {
this.addBanzaiTeleporter(interactionBattleBanzaiTeleporter);
} else if (item instanceof InteractionRoller interactionRoller) {
this.addRoller(interactionRoller);
} else if (item instanceof InteractionGameScoreboard interactionGameScoreboard) {
this.addGameScoreboard(interactionGameScoreboard);
} else if (item instanceof InteractionGameGate interactionGameGate) {
this.addGameGate(interactionGameGate);
} else if (item instanceof InteractionGameTimer interactionGameTimer) {
this.addGameTimer(interactionGameTimer);
} else if (item instanceof InteractionFreezeExitTile interactionFreezeExitTile) {
this.addFreezeExitTile(interactionFreezeExitTile);
} else if (item instanceof InteractionNest interactionNest) {
this.addNest(interactionNest);
} else if (item instanceof InteractionPetDrink interactionPetDrink) {
this.addPetDrink(interactionPetDrink);
} else if (item instanceof InteractionPetFood interactionPetFood) {
this.addPetFood(interactionPetFood);
} else if (item instanceof InteractionPetToy interactionPetToy) {
this.addPetToy(interactionPetToy);
} else if (item instanceof InteractionPetTree) {
this.addUndefined(item);
} else if (item instanceof InteractionPetTrampoline) {
this.addUndefined(item);
} else if (item instanceof InteractionMoodLight) {
this.addUndefined(item);
} else if (item instanceof InteractionPyramid) {
this.addUndefined(item);
} else if (item instanceof InteractionMusicDisc) {
this.addUndefined(item);
} else if (item instanceof InteractionBattleBanzaiSphere) {
this.addUndefined(item);
} else if (item instanceof InteractionTalkingFurniture) {
this.addUndefined(item);
} else if (item instanceof InteractionWater) {
this.addUndefined(item);
} else if (item instanceof InteractionWaterItem) {
this.addUndefined(item);
} else if (item instanceof InteractionMuteArea) {
this.addUndefined(item);
} else if (item instanceof InteractionBuildArea) {
this.addUndefined(item);
} else if (item instanceof InteractionTagPole) {
this.addUndefined(item);
} else if (item instanceof InteractionTagField) {
this.addUndefined(item);
} else if (item instanceof InteractionJukeBox) {
this.addUndefined(item);
} else if (item instanceof InteractionPetBreedingNest) {
this.addUndefined(item);
} else if (item instanceof InteractionBlackHole) {
this.addUndefined(item);
} else if (item instanceof InteractionWiredHighscore) {
this.addUndefined(item);
} else if (item instanceof InteractionStickyPole) {
this.addUndefined(item);
} else if (item instanceof WiredBlob) {
this.addUndefined(item);
} else if (item instanceof InteractionTent) {
this.addUndefined(item);
} else if (item instanceof InteractionSnowboardSlope) {
this.addUndefined(item);
} else if (item instanceof InteractionFireworks) {
this.addUndefined(item);
}
}
}

View File

@ -27,8 +27,8 @@ import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.*;
public class RoomSpecialTypes {
private final THashMap<Integer, InteractionBattleBanzaiTeleporter> banzaiTeleporters;
@ -636,14 +636,14 @@ public class RoomSpecialTypes {
}
}
public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) {
this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile);
}
public THashMap<Integer, InteractionFreezeExitTile> getFreezeExitTiles() {
return this.freezeExitTile;
}
public void addFreezeExitTile(InteractionFreezeExitTile freezeExitTile) {
this.freezeExitTile.put(freezeExitTile.getId(), freezeExitTile);
}
public void removeFreezeExitTile(InteractionFreezeExitTile freezeExitTile) {
this.freezeExitTile.remove(freezeExitTile.getId());
}

View File

@ -36,7 +36,7 @@ import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
@Slf4j
@Getter
public class RoomUnitManager {
private final int roomId;
private final Room room;
private final ConcurrentHashMap<Integer, RoomUnit> currentRoomUnits;
private final ConcurrentHashMap<Integer, Habbo> currentRoomHabbos;
private final ConcurrentHashMap<Integer, Bot> currentRoomBots;
@ -44,15 +44,13 @@ public class RoomUnitManager {
private volatile int roomUnitCounter;
public final Object roomUnitLock;
public RoomUnitManager(int roomId) {
this.roomId = roomId;
public RoomUnitManager(Room room) {
this.room = room;
this.currentRoomUnits = new ConcurrentHashMap<>();
this.currentRoomHabbos = new ConcurrentHashMap<>();
this.currentRoomBots = new ConcurrentHashMap<>();
this.currentRoomPets = new ConcurrentHashMap<>();
this.roomUnitCounter = 0;
this.roomUnitLock = new Object();
}
@ -62,23 +60,23 @@ public class RoomUnitManager {
}
private synchronized void loadBots(Connection connection) {
this.currentRoomBots.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.roomId);
statement.setInt(1, this.room.getRoomInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Bot bot = Emulator.getGameEnvironment().getBotManager().loadBot(set);
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.roomId);
if (bot != null && room != null) {
bot.setRoom(room);
if (bot != null) {
bot.setRoom(this.room);
bot.setRoomUnit(new RoomBot());
bot.getRoomUnit().setRoom(room);
bot.getRoomUnit().setLocation(room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
bot.getRoomUnit().setRoom(this.room);
bot.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
if (bot.getRoomUnit().getCurrentPosition() == null || bot.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
bot.getRoomUnit().setCurrentZ(room.getLayout().getDoorTile().getStackHeight());
bot.getRoomUnit().setLocation(room.getLayout().getDoorTile());
bot.getRoomUnit().setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection()));
bot.getRoomUnit().setCurrentZ(this.room.getLayout().getDoorTile().getStackHeight());
bot.getRoomUnit().setLocation(this.room.getLayout().getDoorTile());
bot.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection()));
} else {
bot.getRoomUnit().setCurrentZ(set.getDouble("z"));
bot.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
@ -87,7 +85,7 @@ public class RoomUnitManager {
bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
bot.getRoomUnit().setInRoom(true);
room.giveEffect(bot.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE);
this.room.giveEffect(bot.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE);
this.addRoomUnit(bot);
}
}
@ -100,21 +98,22 @@ public class RoomUnitManager {
}
private synchronized void loadPets(Connection connection) {
this.currentRoomPets.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.roomId);
statement.setInt(1, this.room.getRoomInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Pet pet = PetManager.loadPet(set);
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.roomId);
pet.setRoom(room);
pet.setRoom(this.room);
pet.setRoomUnit(new RoomPet());
pet.getRoomUnit().setRoom(room);
pet.getRoomUnit().setLocation(room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
pet.getRoomUnit().setRoom(this.room);
pet.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
if (pet.getRoomUnit().getCurrentPosition() == null || pet.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
pet.getRoomUnit().setCurrentZ(room.getLayout().getDoorTile().getStackHeight());
pet.getRoomUnit().setLocation(room.getLayout().getDoorTile());
pet.getRoomUnit().setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection()));
pet.getRoomUnit().setCurrentZ(this.room.getLayout().getDoorTile().getStackHeight());
pet.getRoomUnit().setLocation(this.room.getLayout().getDoorTile());
pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.room.getLayout().getDoorDirection()));
} else {
pet.getRoomUnit().setCurrentZ(set.getDouble("z"));
pet.getRoomUnit().setRotation(RoomRotation.values()[set.getInt("rot")]);
@ -122,7 +121,7 @@ public class RoomUnitManager {
pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET);
pet.getRoomUnit().setCanWalk(true);
this.addRoomUnit(pet);
room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name"));
this.room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name"));
}
}
} catch (SQLException e) {
@ -138,23 +137,19 @@ public class RoomUnitManager {
this.currentRoomUnits.put(unit.getRoomUnit().getVirtualId(), unit.getRoomUnit());
this.roomUnitCounter++;
switch(unit.getRoomUnit().getRoomUnitType()) {
case HABBO:
switch (unit.getRoomUnit().getRoomUnitType()) {
case HABBO -> {
this.currentRoomHabbos.put(((Habbo) unit).getHabboInfo().getId(), (Habbo) unit);
unit.getRoomUnit().getRoom().updateDatabaseUserCount();
break;
case BOT:
this.currentRoomBots.put(((Bot) unit).getId(), (Bot) unit);
break;
case PET:
}
case BOT -> this.currentRoomBots.put(((Bot) unit).getId(), (Bot) unit);
case PET -> {
this.currentRoomPets.put(((Pet) unit).getId(), (Pet) unit);
Habbo habbo = this.getRoomHabboById(((Pet) unit).getUserId());
if (habbo != null) {
unit.getRoomUnit().getRoom().getFurniOwnerNames().put(((Pet) unit).getUserId(), this.getRoomHabboById(((Pet) unit).getUserId()).getHabboInfo().getUsername());
}
break;
}
}
}
}
@ -185,10 +180,15 @@ public class RoomUnitManager {
public Habbo getRoomHabboById(int habboId) {
return this.currentRoomHabbos.get(habboId);
}
public Habbo getRoomHabboByUsername(String username) {
return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)).findFirst().orElse(null);
}
public Habbo getHabboByVirtualId(int virtualId) {
return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit().getVirtualId() == virtualId).findFirst().orElse(null);
}
public Habbo getHabboByRoomUnit(RoomUnit roomUnit) {
return this.currentRoomHabbos.values().stream().filter(habbo -> habbo.getRoomUnit() == roomUnit).findFirst().orElse(null);
}

View File

@ -0,0 +1,123 @@
package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.habbohotel.items.interactions.*;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
@Getter
public class RoomWiredManager {
private final ConcurrentHashMap<Integer, InteractionWired> currentWireds;
private final ConcurrentHashMap<WiredTriggerType, Set<InteractionWiredTrigger>> currentWiredTriggers;
private final ConcurrentHashMap<WiredEffectType, Set<InteractionWiredEffect>> currentWiredEffects;
private final ConcurrentHashMap<WiredConditionType, Set<InteractionWiredCondition>> currentWiredConditions;
private final ConcurrentHashMap<Integer, InteractionWiredExtra> currentWiredExtras;
public RoomWiredManager() {
this.currentWireds = new ConcurrentHashMap<>(0);
this.currentWiredTriggers = new ConcurrentHashMap<>(0);
this.currentWiredEffects = new ConcurrentHashMap<>(0);
this.currentWiredConditions = new ConcurrentHashMap<>(0);
this.currentWiredExtras = new ConcurrentHashMap<>(0);
}
public void addWired(InteractionWired wired) {
this.currentWireds.put(wired.getId(), wired);
sortWired(wired);
}
public void removeWired(InteractionWired wired) {
InteractionWired w = this.currentWireds.remove(wired.getId());
if (w instanceof InteractionWiredTrigger trigger) {
removeWiredTrigger(trigger);
} else if (w instanceof InteractionWiredEffect effect) {
removeWiredEffect(effect);
} else if (w instanceof InteractionWiredCondition condition) {
removeWiredCondition(condition);
} else if (w instanceof InteractionWiredExtra extra) {
removeWiredExtra(extra);
} else {
log.error("Error occurred while removing undefined Wired Type");
}
}
private void sortWired(InteractionWired wired) {
if (wired instanceof InteractionWiredTrigger trigger) {
addWiredTrigger(trigger);
} else if (wired instanceof InteractionWiredEffect effect) {
addWiredEffect(effect);
} else if (wired instanceof InteractionWiredCondition condition) {
addWiredCondition(condition);
} else if (wired instanceof InteractionWiredExtra extra) {
addWiredExtra(extra);
} else {
log.error("Undefined Wired Type");
}
}
public void addWiredTrigger(InteractionWiredTrigger trigger) {
currentWiredTriggers.computeIfAbsent(trigger.getType(), k -> Collections.newSetFromMap(new ConcurrentHashMap<>())).add(trigger);
}
public void removeWiredTrigger(InteractionWiredTrigger trigger) {
Set<InteractionWiredTrigger> triggers = currentWiredTriggers.get(trigger.getType());
if (triggers != null) {
triggers.remove(trigger);
if (triggers.isEmpty()) {
currentWiredTriggers.remove(trigger.getType());
}
}
}
public void addWiredEffect(InteractionWiredEffect effect) {
currentWiredEffects.computeIfAbsent(effect.getType(), k -> Collections.newSetFromMap(new ConcurrentHashMap<>())).add(effect);
}
public void removeWiredEffect(InteractionWiredEffect effect) {
Set<InteractionWiredEffect> effects = currentWiredEffects.get(effect.getType());
if (effects != null) {
effects.remove(effect);
if (effects.isEmpty()) {
currentWiredEffects.remove(effect.getType());
}
}
}
public void addWiredCondition(InteractionWiredCondition condition) {
currentWiredConditions.computeIfAbsent(condition.getType(), k -> Collections.newSetFromMap(new ConcurrentHashMap<>())).add(condition);
}
public void removeWiredCondition(InteractionWiredCondition condition) {
Set<InteractionWiredCondition> conditions = currentWiredConditions.get(condition.getType());
if (conditions != null) {
conditions.remove(condition);
if (conditions.isEmpty()) {
currentWiredConditions.remove(condition.getType());
}
}
}
public void addWiredExtra(InteractionWiredExtra extra) {
currentWiredExtras.put(extra.getId(), extra);
}
public void removeWiredExtra(InteractionWiredExtra extra) {
currentWiredExtras.remove(extra.getId());
}
public void clear() {
this.currentWireds.clear();
this.currentWiredTriggers.clear();
this.currentWiredConditions.clear();
this.currentWiredEffects.clear();
this.currentWiredExtras.clear();
}
}

View File

@ -272,7 +272,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
}
if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoalLocation() && roomUnit.getGoalLocation() == room.getLayout().getTile(this.x, this.y)) {
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && habbo.getClient() != null) {
String[] clothingKeys = Arrays.stream(this.getBaseItem().getClothingOnWalk().split("\\.")).map(k -> k.split("-")[0]).toArray(String[]::new);
@ -459,7 +459,7 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
return this.baseItem.getStateCount() > 1;
}
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
public boolean canStackAt(List<Pair<RoomTile, THashSet<RoomItem>>> itemsAtLocation) {
return true;
}

View File

@ -1,30 +0,0 @@
package com.eu.habbo.habbohotel.rooms.entities.items.types;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RoomFloorItem extends RoomItem {
public RoomFloorItem(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
@Override
public boolean isWalkable() {
return false;
}
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
}

View File

@ -1,30 +0,0 @@
package com.eu.habbo.habbohotel.rooms.entities.items.types;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RoomWallItem extends RoomItem {
public RoomWallItem(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
@Override
public boolean isWalkable() {
return false;
}
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
}

View File

@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.rooms.*;
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.types.RoomFloorItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo;
@ -299,7 +298,7 @@ public class RoomAvatar extends RoomUnit {
return this;
}
private void handleSitStatus(RoomFloorItem topItem) {
private void handleSitStatus(RoomItem topItem) {
if(!this.isCmdSitEnabled()) {
if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) {
this.removeStatus(RoomUnitStatus.SIT);
@ -311,7 +310,7 @@ public class RoomAvatar extends RoomUnit {
}
}
private void handleLayStatus(RoomFloorItem topItem) {
private void handleLayStatus(RoomItem topItem) {
if(!this.isCmdLayEnabled()) {
if((topItem == null || !topItem.getBaseItem().allowLay()) && this.hasStatus(RoomUnitStatus.LAY)) {
this.removeStatus(RoomUnitStatus.LAY);

View File

@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
@ -59,7 +60,7 @@ public class Habbo extends Unit implements Runnable {
private volatile boolean disconnected = false;
private volatile boolean disconnecting = false;
public Habbo(ResultSet set) {
public Habbo(ResultSet set) throws SQLException {
this.client = null;
this.habboInfo = new HabboInfo(set);
this.habboStats = HabboStats.load(this.habboInfo);

View File

@ -26,91 +26,64 @@ import java.util.List;
@Slf4j
@Getter
@Setter
@Accessors(chain = true)
public class HabboInfo implements Runnable {
public boolean firstVisit = false;
@Setter
private final int id;
private String username;
@Setter
private String motto;
@Setter
@Accessors(chain = true)
private String look;
@Setter
private HabboGender gender;
@Setter
private String mail;
@Setter
private String sso;
@Setter
private String ipRegister;
@Setter
private String ipLogin;
private int id;
@Setter
private int accountCreated;
@Setter
private PermissionGroup permissionGroup;
private int credits;
@Setter
private int lastOnline;
@Setter
private int homeRoom;
@Setter
private boolean online;
@Setter
private int roomQueueId;
@Setter
private RideablePet riding;
@Setter
private Class<? extends Game> currentGame;
private TIntIntHashMap currencies;
@Setter
private GamePlayer gamePlayer;
@Setter
private int photoRoomId;
@Setter
private int photoTimestamp;
@Setter
private String photoURL;
@Setter
private String photoJSON;
@Setter
private int webPublishTimestamp;
@Setter
private String machineID;
private List<NavigatorSavedSearch> savedSearches = new ArrayList<>();
private List<MessengerCategory> messengerCategories = new ArrayList<>();
public boolean firstVisit = false;
public HabboInfo(ResultSet set) {
try {
this.id = set.getInt("id");
this.username = set.getString("username");
this.motto = set.getString("motto");
this.look = set.getString("look");
this.gender = HabboGender.valueOf(set.getString("gender"));
this.mail = set.getString("mail");
this.sso = set.getString("auth_ticket");
this.ipRegister = set.getString("ip_register");
this.ipLogin = set.getString("ip_current");
this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(set.getInt("rank"));
public HabboInfo(ResultSet set) throws SQLException {
this.id = set.getInt("id");
this.username = set.getString("username");
this.motto = set.getString("motto");
this.look = set.getString("look");
this.gender = HabboGender.valueOf(set.getString("gender"));
this.mail = set.getString("mail");
this.sso = set.getString("auth_ticket");
this.ipRegister = set.getString("ip_register");
this.ipLogin = set.getString("ip_current");
this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(set.getInt("rank"));
if (this.permissionGroup == null) {
log.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
log.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(1);
}
this.accountCreated = set.getInt("account_created");
this.credits = set.getInt("credits");
this.homeRoom = set.getInt("home_room");
this.lastOnline = set.getInt("last_online");
this.machineID = set.getString("machine_id");
this.online = false;
} catch (SQLException e) {
log.error("Caught SQL exception", e);
if (this.permissionGroup == null) {
log.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
log.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists.");
this.permissionGroup = Emulator.getGameEnvironment().getPermissionsManager().getGroup(1);
}
this.accountCreated = set.getInt("account_created");
this.credits = set.getInt("credits");
this.homeRoom = set.getInt("home_room");
this.lastOnline = set.getInt("last_online");
this.machineID = set.getString("machine_id");
this.online = false;
this.loadCurrencies();
this.loadSavedSearches();
this.loadMessengerCategories();

View File

@ -28,10 +28,8 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class HabboManager {
//Configuration. Loaded from database & updated accordingly.
public static String WELCOME_MESSAGE = "";
public static boolean NAMECHANGE_ENABLED = false;
@Getter
private final ConcurrentHashMap<Integer, Habbo> onlineHabbos;

View File

@ -0,0 +1,22 @@
package com.eu.habbo.habbohotel.users.cache;
import com.eu.habbo.habbohotel.users.HabboInfo;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import java.util.LinkedHashMap;
import java.util.Map;
@Slf4j
@Getter
public class HabboInfoCache {
private final LinkedHashMap<Integer, HabboInfo> habboInfoCache;
public HabboInfoCache() {
this.habboInfoCache = new LinkedHashMap<Integer, HabboInfo>(16, 0.75f, true) {
protected boolean removeEldestEntry(Map.Entry<Integer, HabboInfo> eldest) {
return false;
}
};
}
}

View File

@ -14,10 +14,10 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen;
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset;
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.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.outgoing.catalog.PurchaseOKMessageComposer;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
@ -43,7 +43,6 @@ import java.util.List;
public class WiredHandler {
public static int MAXIMUM_FURNI_SELECTION = 5;
public static int TELEPORT_DELAY = 500;
private static ObjectMapper objectMapper = null;
public static boolean handle(WiredTriggerType triggerType, RoomUnit roomUnit, Room room, Object[] stuff) {

View File

@ -16,42 +16,33 @@ import com.eu.habbo.messages.outgoing.inventory.FurniListRemoveComposer;
public class PlaceObjectEvent extends MessageHandler {
@Override
public void handle() {
String[] values = this.packet.readString().split(" ");
int itemId = -1;
if (values.length != 0) itemId = Integer.parseInt(values[0]);
if (!this.client.getHabbo().getRoomUnit().isInRoom()) {
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode()));
return;
}
Room room = this.client.getHabbo().getRoomUnit().getRoom();
if (room == null) {
return;
}
RoomItem rentSpace = null;
if (this.client.getHabbo().getHabboStats().isRentingSpace()) {
rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId());
String[] values = this.packet.readString().split(" ");
int itemId = -1;
if (values.length != 0) {
itemId = Integer.parseInt(values[0]);
}
RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId);
if (item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class)
return;
if (room.getRoomInfo().getId() != item.getRoomId() && item.getRoomId() != 0)
return;
//TODO move this to canStackAt() though find a way to handle the different bubble alert keys
if (item instanceof InteractionMoodLight && !room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) {
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_DIMMERS.getErrorCode()));
//PostIts have their own event
if (item == null || item.getBaseItem().getInteractionType().getType() == InteractionPostIt.class) {
return;
}
if (item instanceof InteractionJukeBox && !room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) {
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.MAX_SOUNDFURNI.getErrorCode()));
if (room.getRoomInfo().getId() != item.getRoomId() && item.getRoomId() != 0) {
return;
}
@ -71,12 +62,19 @@ public class PlaceObjectEvent extends MessageHandler {
}
RoomItem buildArea = null;
for (RoomItem area : room.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) {
if (((InteractionBuildArea) area).inSquare(tile)) {
buildArea = area;
}
}
RoomItem rentSpace = null;
if (this.client.getHabbo().getHabboStats().isRentingSpace()) {
rentSpace = room.getHabboItem(this.client.getHabbo().getHabboStats().getRentedItemId());
}
if ((rentSpace != null || buildArea != null) && !room.hasRights(this.client.getHabbo())) {
if (item instanceof InteractionRoller ||
item instanceof InteractionStackHelper ||
@ -94,18 +92,14 @@ public class PlaceObjectEvent extends MessageHandler {
return;
}
}
FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation);
FurnitureMovementError error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo());
if (!error.equals(FurnitureMovementError.NONE)) {
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode()));
return;
}
error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo());
if (!error.equals(FurnitureMovementError.NONE)) {
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode()));
return;
}
} else {
FurnitureMovementError error = room.placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo());
if (!error.equals(FurnitureMovementError.NONE)) {

View File

@ -10,7 +10,7 @@ public class GetUserTagsEvent extends MessageHandler {
int roomUnitId = this.packet.readInt();
if (this.client.getHabbo().getRoomUnit().getRoom() != null) {
Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getHabboByRoomUnitId(roomUnitId);
Habbo habbo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getHabboByVirtualId(roomUnitId);
if (habbo != null) {
this.client.sendResponse(new UserTagsMessageComposer(habbo));

View File

@ -15,7 +15,7 @@ public class IgnoreUserEvent extends MessageHandler {
if (room != null) {
String username = this.packet.readString();
Habbo habbo = room.getHabbo(username);
Habbo habbo = room.getRoomUnitManager().getRoomHabboByUsername(username);
if (habbo != null) {
if (habbo == this.client.getHabbo())

View File

@ -13,7 +13,7 @@ public class UnignoreUserEvent extends MessageHandler {
if (room != null) {
String username = this.packet.readString();
Habbo habbo = room.getHabbo(username);
Habbo habbo = room.getRoomUnitManager().getRoomHabboByUsername(username);
if (habbo != null) {
if (habbo.getHabboStats().allowTalk()) {

View File

@ -19,7 +19,7 @@ public class OpenTradingEvent extends MessageHandler {
Room room = this.client.getHabbo().getRoomUnit().getRoom();
if (room != null) {
if (userId >= 0 && userId != this.client.getHabbo().getRoomUnit().getVirtualId()) {
Habbo targetUser = room.getHabboByRoomUnitId(userId);
Habbo targetUser = room.getRoomUnitManager().getHabboByVirtualId(userId);
boolean tradeAnywhere = this.client.getHabbo().hasRight(Permission.ACC_TRADE_ANYWHERE);