diff --git a/src/main/java/com/eu/habbo/core/Easter.java b/src/main/java/com/eu/habbo/core/Easter.java index 752f1345..64ed50b2 100644 --- a/src/main/java/com/eu/habbo/core/Easter.java +++ b/src/main/java/com/eu/habbo/core/Easter.java @@ -2,7 +2,7 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer; diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index a99f0d6d..0361c32e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.constants.RoomUserAction; import com.eu.habbo.habbohotel.rooms.bots.entities.RoomBot; diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index f9a77adb..4137b658 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -1,7 +1,7 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java index bcca553e..a980f57a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.bots; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolRoomVisit; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.set.hash.THashSet; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java index 0f533c07..3228f347 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java @@ -149,11 +149,11 @@ public class CommandsManager { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); - if (room.getRoomUnitManager().getCurrentPets().isEmpty()) { + if (room.getRoomUnitManager().getRoomPetManager().getCurrentPets().isEmpty()) { return false; } - for(Pet pet : room.getRoomUnitManager().getCurrentPets().values()) { + for(Pet pet : room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values()) { if (pet != null && pet.getName().equalsIgnoreCase(args[0])) { StringBuilder commandBuilder = new StringBuilder(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java index 5c4e237e..6056628c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java @@ -20,7 +20,7 @@ public class LayCommand extends Command { return true; gameClient.getHabbo().getRoomUnit().setCmdLayEnabled(true); - gameClient.getHabbo().getRoomUnit().getRoom().updateRoomUnit(gameClient.getHabbo().getRoomUnit()); + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().updateRoomUnit(gameClient.getHabbo().getRoomUnit()); gameClient.getHabbo().getRoomUnit().setCmdSitEnabled(true); gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java index 4d6d8bb3..f5996bee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java @@ -21,7 +21,7 @@ public class PetInfoCommand extends Command { String name = params[1]; - gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentPets().forEach((a, pet) -> { + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getCurrentPets().forEach((a, pet) -> { if (pet.getName().equalsIgnoreCase(name)) { gameClient.getHabbo().alert("" + getTextsValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" + diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java index d9fbe130..ed6de012 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java index 36110657..31988b9f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java index 11fde506..10a42799 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java @@ -20,7 +20,7 @@ public class RedeemCommand extends Command { @Override public boolean handle(final GameClient gameClient, String[] params) { - if (gameClient.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(gameClient.getHabbo()) != null) + if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomTradeManager().getActiveTradeForHabbo(gameClient.getHabbo()) != null) return false; ArrayList items = new ArrayList<>(); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java index 4d1406b3..cae1d742 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java @@ -16,8 +16,8 @@ public class RoomMuteCommand extends Command { Room room = gameClient.getHabbo().getRoomUnit().getRoom(); if (room != null) { - room.setMuted(!room.isMuted()); - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roommute." + (room.isMuted() ? "muted" : "unmuted")), RoomChatMessageBubbles.ALERT); + room.getRoomChatManager().setMuted(!room.getRoomChatManager().isMuted()); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_roommute." + (room.getRoomChatManager().isMuted() ? "muted" : "unmuted")), RoomChatMessageBubbles.ALERT); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java index b0830885..ace1b616 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.ChatMessageComposer; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java index 653c766c..50c3fc6f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.ShoutMessageComposer; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShutdownCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShutdownCommand.java index 78abb4e2..631afd84 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShutdownCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShutdownCommand.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HotelWillCloseInMinutesComposer; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java index b0100752..4059018b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.commands.list; import com.eu.habbo.habbohotel.commands.Command; import com.eu.habbo.habbohotel.gameclients.GameClient; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java index 13598060..9000ef10 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java @@ -25,13 +25,13 @@ public class UnmuteCommand extends Command { return true; } - if (!habbo.getHabboStats().allowTalk() || (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().isMuted(habbo))) { + if (!habbo.getHabboStats().allowTalk() || (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().getRoomInfractionManager().isMuted(habbo))) { if (!habbo.getHabboStats().allowTalk()) { habbo.unMute(); } - if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().isMuted(habbo)) { - habbo.getRoomUnit().getRoom().muteHabbo(habbo, 1); + if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().getRoomInfractionManager().isMuted(habbo)) { + habbo.getRoomUnit().getRoom().getRoomInfractionManager().muteHabbo(habbo, 1); } gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_unmute"), params[1]), RoomChatMessageBubbles.ALERT); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java index 93aa25b3..3f7f42d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java @@ -13,7 +13,7 @@ public class WordQuizCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) { - if (!gameClient.getHabbo().getRoomUnit().getRoom().hasActiveWordQuiz()) { + if (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomWordQuizManager().hasActiveWordQuiz()) { if(params.length == 1) { gameClient.getHabbo().whisper(getTextsValue("commands.description.cmd_word_quiz"), RoomChatMessageBubbles.ALERT); return true; @@ -31,7 +31,7 @@ public class WordQuizCommand extends Command { question.append(" ").append(params[i]); } - gameClient.getHabbo().getRoomUnit().getRoom().startWordQuiz(question.toString(), duration * 1000); + gameClient.getHabbo().getRoomUnit().getRoom().getRoomWordQuizManager().startWordQuiz(question.toString(), duration * 1000); } return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java index 8c0caf6b..eee0c15c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java @@ -137,7 +137,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC if (roomUnit != null) { roomUnit.setRotation(RoomRotation.fromValue(rotation)); - room.updateRoomUnit(roomUnit); + room.getRoomUnitManager().updateRoomUnit(roomUnit); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java index 5507c237..2c03212b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java @@ -97,7 +97,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable { Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { if (roomUnit.getBodyRotation().getValue() % 2 == 0) { @@ -126,7 +126,7 @@ public class InteractionObstacle extends RoomItem implements ICycleable { Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit); if (habbo == null) { - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java index d3a78cd9..a4b90d1c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java @@ -83,7 +83,7 @@ public class InteractionWater extends InteractionDefault { if(roomUnit == null) return; roomUnit.setSwimming(true); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet == null) return; @@ -100,7 +100,7 @@ public class InteractionWater extends InteractionDefault { super.onWalkOff(roomUnit, room, objects); if ( roomUnit.getRoomUnitType() != RoomUnitType.PET) return; - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet == null) return; @@ -133,7 +133,7 @@ public class InteractionWater extends InteractionDefault { public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { if (!super.canWalkOn(roomUnit, room, objects)) return false; - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); return pet == null || pet.getPetData().isCanSwim(); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java index f994139a..4fc100b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java @@ -68,7 +68,7 @@ public class InteractionNest extends RoomItem { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet == null) return; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java index 64733caf..afb2b8d8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java @@ -35,7 +35,7 @@ public class InteractionPetBreedingNest extends RoomItem { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - return room.getRoomUnitManager().getPetByRoomUnit(roomUnit) != null && !this.boxFull(); + return room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit) != null && !this.boxFull(); } @Override @@ -59,7 +59,7 @@ public class InteractionPetBreedingNest extends RoomItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null && !this.boxFull()) { this.addPet(pet); @@ -153,7 +153,7 @@ public class InteractionPetBreedingNest extends RoomItem { Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient()); - habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getCurrentPosition().getX(), box.getCurrentPosition().getY(), box.getCurrentZ()); + habbo.getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getCurrentPosition().getX(), box.getCurrentPosition().getY(), box.getCurrentZ()); offspring.setSqlUpdateNeeded(true); offspring.run(); InteractionPetBreedingNest.this.freePets(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java index bca82141..50bf014f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java @@ -71,7 +71,7 @@ public class InteractionPetDrink extends InteractionDefault { if (this.getExtraData() == null || this.getExtraData().isEmpty()) this.setExtraData("0"); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) { pet.clearPosture(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java index 24669e62..0f0133f7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java @@ -33,7 +33,7 @@ public class InteractionPetFood extends InteractionDefault { if (this.getExtraData().length() == 0) this.setExtraData("0"); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null) { if (pet.getPetData().haveFoodItem(this)) { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java index e027b473..22c287d1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java @@ -38,7 +38,7 @@ public class InteractionPetToy extends InteractionDefault { this.setExtraData("0"); room.updateItem(this); - for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { + for (Pet pet : room.getRoomUnitManager().getRoomPetManager().getPetsAt(oldLocation)) { pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } @@ -57,7 +57,7 @@ public class InteractionPetToy extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) { if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) { @@ -90,7 +90,7 @@ public class InteractionPetToy extends InteractionDefault { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null) { this.setExtraData("0"); @@ -102,7 +102,7 @@ public class InteractionPetToy extends InteractionDefault { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java index 53e9579e..dd0b24a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java @@ -38,7 +38,7 @@ public class InteractionPetTrampoline extends InteractionDefault { this.setExtraData("0"); room.updateItem(this); - for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { + for (Pet pet : room.getRoomUnitManager().getRoomPetManager().getPetsAt(oldLocation)) { pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); pet.setPacketUpdate(true); } @@ -58,7 +58,7 @@ public class InteractionPetTrampoline extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) { if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) { @@ -87,7 +87,7 @@ public class InteractionPetTrampoline extends InteractionDefault { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null) { this.setExtraData("0"); @@ -99,7 +99,7 @@ public class InteractionPetTrampoline extends InteractionDefault { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java index f47cde4a..d209d5ee 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java @@ -28,7 +28,7 @@ public class InteractionPetTree extends InteractionDefault { @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { - for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) { + for (Pet pet : room.getRoomUnitManager().getRoomPetManager().getPetsAt(oldLocation)) { pet.getRoomUnit().clearStatuses(); pet.setPacketUpdate(true); } @@ -45,7 +45,7 @@ public class InteractionPetTree extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) { if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) { RoomUnitStatus task = switch (pet.getTask()) { @@ -88,7 +88,7 @@ public class InteractionPetTree extends InteractionDefault { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); if (pet != null) { pet.getRoomUnit().clearStatuses(); @@ -98,7 +98,7 @@ public class InteractionPetTree extends InteractionDefault { @Override public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { - Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getPetByRoomUnit(roomUnit); return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem()); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java index 89fbe17d..26f719c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java @@ -33,7 +33,7 @@ public class WiredConditionFurniHaveRoom extends InteractionWiredCondition { Collection habbos = room.getRoomUnitManager().getCurrentHabbos().values(); Collection bots = room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values(); - Collection pets = room.getRoomUnitManager().getCurrentPets().values(); + Collection pets = room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values(); return this.getWiredSettings().getItems(room).stream().allMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java index be7baf1e..d1c3d6ed 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java @@ -33,7 +33,7 @@ public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition { Collection habbos = room.getRoomUnitManager().getCurrentHabbos().values(); Collection bots = room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values(); - Collection pets = room.getRoomUnitManager().getCurrentPets().values(); + Collection pets = room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values(); return this.getWiredSettings().getItems(room).stream().noneMatch(item -> { THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java index 345e5134..7f1ea0f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickRoom.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java index ced82450..7b767445 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteRoom.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -40,7 +40,7 @@ public class WiredEffectMuteRoom extends InteractionWiredEffect { if (room.getRoomRightsManager().hasRights(habbo)) return false; - room.muteHabbo(habbo, 60); + room.getRoomInfractionManager().muteHabbo(habbo, 60); habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(message.replace("%user%", habbo.getHabboInfo().getUsername()).replace("%online_count%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "").replace("%room_count%", Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size() + ""), habbo, habbo, RoomChatMessageBubbles.WIRED))); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 8432599b..f758686c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index 5c625d03..9b7cbd6c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Message; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.friends.NewConsoleMessageComposer; import com.eu.habbo.plugin.events.users.UserTriggerWordFilterEvent; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 39f305c0..70301c05 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -4,10 +4,11 @@ import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; +import com.eu.habbo.habbohotel.rooms.pets.entities.RoomPet; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ISerialize; @@ -739,7 +740,7 @@ public class Pet extends Unit implements ISerialize, Runnable { if (!dontSendPackets) { room.sendComposer(new UserRemoveMessageComposer(this.getRoomUnit()).compose()); - room.getRoomUnitManager().removePet(this.id); + room.getRoomUnitManager().getRoomPetManager().removePet(this.id); } this.roomUnit.setRoom(null); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 86c79146..17e8b9b4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1,8 +1,6 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import com.eu.habbo.database.DatabaseConstants; -import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.VisitorBot; import com.eu.habbo.habbohotel.games.Game; @@ -15,43 +13,33 @@ import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.RideablePet; -import com.eu.habbo.habbohotel.rooms.constants.*; -import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatManager; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; +import com.eu.habbo.habbohotel.rooms.constants.RoomRightLevels; +import com.eu.habbo.habbohotel.rooms.constants.RoomTileState; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; -import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; +import com.eu.habbo.habbohotel.rooms.infractions.RoomInfractionManager; import com.eu.habbo.habbohotel.rooms.items.RoomItemManager; +import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; +import com.eu.habbo.habbohotel.rooms.promotions.RoomPromotionManager; +import com.eu.habbo.habbohotel.rooms.trades.RoomTradeManager; +import com.eu.habbo.habbohotel.rooms.wordquiz.RoomWordQuizManager; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer; import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer; -import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer; -import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; import com.eu.habbo.messages.outgoing.rooms.FlatAccessDeniedMessageComposer; import com.eu.habbo.messages.outgoing.rooms.FlatAccessibleMessageComposer; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.items.ItemUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectUpdateMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer; -import com.eu.habbo.messages.outgoing.rooms.users.*; -import com.eu.habbo.messages.outgoing.users.RemainingMutePeriodComposer; -import com.eu.habbo.plugin.Event; -import com.eu.habbo.plugin.events.furniture.FurnitureRolledEvent; import com.eu.habbo.plugin.events.furniture.FurnitureStackHeightEvent; import com.eu.habbo.plugin.events.rooms.RoomLoadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadingEvent; -import com.eu.habbo.plugin.events.users.UserIdleEvent; -import com.eu.habbo.plugin.events.users.UserRolledEvent; -import com.eu.habbo.plugin.events.users.UsernameTalkEvent; -import com.eu.habbo.threading.runnables.YouAreAPirate; import gnu.trove.TCollections; import gnu.trove.map.TIntIntMap; import gnu.trove.map.TIntObjectMap; @@ -73,10 +61,8 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import java.util.regex.Pattern; import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; -import static com.eu.habbo.habbohotel.rooms.utils.cycle.CycleFunctions.cycleIdle; @Slf4j public class Room implements Comparable, ISerialize, Runnable { @@ -92,31 +78,21 @@ public class Room implements Comparable, ISerialize, Runnable { private final RoomWordFilterManager roomWordFilterManager; @Getter private RoomTraxManager roomTraxManager; - public static final String CAUGHT_EXCEPTION = "Caught exception"; - public static final Comparator SORT_SCORE = Comparator.comparingInt(room -> room.roomInfo.getScore()); - public static final Comparator SORT_ID = Comparator.comparingInt(room -> room.roomInfo.getId()); - public static final Comparator SORT_USERS_COUNT = Comparator - .comparingInt((Room room) -> room.roomUnitManager.getRoomHabbosCount()) - .thenComparing(Room.SORT_ID); - public static boolean HABBO_CHAT_DELAY = false; - public static int MAXIMUM_BOTS = 10; - public static int MAXIMUM_PETS = 10; - public static int MAXIMUM_FURNI = 2500; - public static int MAXIMUM_POSTITNOTES = 200; - public static int HAND_ITEM_TIME = 10; - public static int IDLE_CYCLES = 240; - public static int IDLE_CYCLES_KICK = 480; - public static String PREFIX_FORMAT = "[%prefix%] "; - public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1; - public static boolean MUTEAREA_CAN_WHISPER = false; - public static final double MAXIMUM_FURNI_HEIGHT = 40d; + @Getter + private final RoomWordQuizManager roomWordQuizManager; + @Getter + private final RoomInfractionManager roomInfractionManager; + @Getter + private final RoomPromotionManager roomPromotionManager; + @Getter + private final RoomTradeManager roomTradeManager; + @Getter + private final RoomChatManager roomChatManager; public final ConcurrentHashMap> tileCache = new ConcurrentHashMap<>(); - public final List userVotes; + @Getter private final TIntObjectMap habboQueue = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); - private final THashSet activeTrades; - private final TIntIntHashMap mutedHabbos; - private final TIntObjectHashMap bannedHabbos; + @Getter private final ConcurrentSet games; @Getter @@ -129,14 +105,7 @@ public class Room implements Comparable, ISerialize, Runnable { public final ConcurrentHashMap.KeySetView scheduledComposers = ConcurrentHashMap.newKeySet(); public ConcurrentHashMap.KeySetView 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 @@ -148,23 +117,16 @@ public class Room implements Comparable, ISerialize, Runnable { @Getter @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 final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30); @Getter @Setter private volatile int lastTimerReset = Emulator.getIntUnixTimestamp(); @Getter - @Setter - private volatile boolean muted; - @Getter private RoomSpecialTypes roomSpecialTypes; private boolean cycleOdd; @Getter @@ -178,25 +140,17 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomItemManager = new RoomItemManager(this); this.roomRightsManager = new RoomRightsManager(this); this.roomWordFilterManager = new RoomWordFilterManager(this); + this.roomWordQuizManager = new RoomWordQuizManager(this); + this.roomInfractionManager = new RoomInfractionManager(this); + this.roomPromotionManager = new RoomPromotionManager(this); + this.roomTradeManager = new RoomTradeManager(this); + this.roomChatManager = new RoomChatManager(this); this.layoutName = set.getString("model"); - this.bannedHabbos = new TIntObjectHashMap<>(); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) { - if (this.roomInfo.isPromoted()) { - statement.setInt(1, this.roomInfo.getId()); - statement.setInt(2, Emulator.getIntUnixTimestamp()); - - try (ResultSet promotionSet = statement.executeQuery()) { - this.roomInfo.setPromoted(false); - if (promotionSet.next()) { - this.roomInfo.setPromoted(true); - this.promotion = new RoomPromotion(this, promotionSet); - } - } - } - - this.loadBans(connection); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + roomPromotionManager.loadPromotions(connection); + roomInfractionManager.loadBans(connection); } catch (SQLException e) { log.error(CAUGHT_SQL_EXCEPTION, e); } @@ -207,19 +161,14 @@ public class Room implements Comparable, ISerialize, Runnable { this.furniOwnerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0)); this.furniOwnerCount = TCollections.synchronizedMap(new TIntIntHashMap(0)); - this.mutedHabbos = new TIntIntHashMap(); this.games = new ConcurrentSet<>(); - this.activeTrades = new THashSet<>(0); - this.userVotes = new ArrayList<>(); - this.triggersOnRoom = new HashMap<>(); } public synchronized void loadData() { synchronized (this.loadLock) { - if (!this.preLoaded || this.loaded) - return; + if (!this.preLoaded || this.loaded) return; this.preLoaded = false; @@ -235,12 +184,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomUnitManager.load(connection); this.roomWordFilterManager.load(connection); - this.loaded = true; - this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } this.roomTraxManager = new RoomTraxManager(this); @@ -270,7 +217,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } } @@ -289,7 +236,7 @@ public class Room implements Comparable, ISerialize, Runnable { log.error("Unknown Room Layout for Room (ID: {})", this.roomInfo.getId()); } } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } } @@ -314,8 +261,7 @@ public class Room implements Comparable, ISerialize, Runnable { } public RoomTileState calculateTileState(RoomTile tile, RoomItem exclude) { - if (tile == null || tile.getState() == RoomTileState.INVALID) - return RoomTileState.INVALID; + if (tile == null || tile.getState() == RoomTileState.INVALID) return RoomTileState.INVALID; RoomTileState result = RoomTileState.OPEN; THashSet items = this.roomItemManager.getItemsAt(tile); @@ -362,62 +308,6 @@ public class Room implements Comparable, ISerialize, Runnable { return result; } - public void updateRoomUnit(RoomUnit roomUnit) { - RoomItem item = this.roomItemManager.getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); - - if ((item == null && !roomUnit.isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit())) - roomUnit.removeStatus(RoomUnitStatus.SIT); - - double oldZ = roomUnit.getCurrentZ(); - - if (item != null) { - if (item.getBaseItem().allowSit()) { - roomUnit.setCurrentZ(item.getCurrentZ()); - } else { - roomUnit.setCurrentZ(item.getCurrentZ() + Item.getCurrentHeight(item)); - } - - if (oldZ != roomUnit.getCurrentZ()) { - this.scheduledTasks.add(() -> { - try { - item.onWalkOn(roomUnit, Room.this, null); - } catch (Exception ignored) { - - } - }); - } - } - - this.sendComposer(new UserUpdateComposer(roomUnit).compose()); - } - - public void startTrade(Habbo userOne, Habbo userTwo) { - RoomTrade trade = new RoomTrade(userOne, userTwo, this); - synchronized (this.activeTrades) { - this.activeTrades.add(trade); - } - - trade.start(); - } - - public void stopTrade(RoomTrade trade) { - synchronized (this.activeTrades) { - this.activeTrades.remove(trade); - } - } - - public RoomTrade getActiveTradeForHabbo(Habbo user) { - synchronized (this.activeTrades) { - for (RoomTrade trade : this.activeTrades) { - for (RoomTradeUser habbo : trade.getRoomTradeUsers()) { - if (habbo.getHabbo() == user) - return trade; - } - } - } - return null; - } - public void updateDatabaseUserCount() { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE rooms SET users = ? WHERE id = ? LIMIT 1")) { statement.setInt(1, this.roomUnitManager.getRoomHabbosCount()); @@ -487,7 +377,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { Emulator.getThreading().run(Room.this::cycle); } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } } } @@ -562,24 +452,22 @@ public class Room implements Comparable, ISerialize, Runnable { } if (this.roomInfo.isPromoted()) { - message.appendString(this.promotion.getTitle()); - message.appendString(this.promotion.getDescription()); - message.appendInt((this.promotion.getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); + message.appendString(roomPromotionManager.getPromotion().getTitle()); + message.appendString(roomPromotionManager.getPromotion().getDescription()); + message.appendInt((roomPromotionManager.getPromotion().getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); } } @Override public int compareTo(Room room) { - return SORT_USERS_COUNT.compare(this, room); + return RoomConfiguration.SORT_USERS_COUNT.compare(this, room); } public synchronized void dispose() { synchronized (this.loadLock) { - if (this.preventUnloading) - return; + if (this.preventUnloading) return; - if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) - return; + if (Emulator.getPluginManager().fireEvent(new RoomUnloadingEvent(this)).isCancelled()) return; if (this.loaded) { try { @@ -595,8 +483,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.tileCache.clear(); - synchronized (this.mutedHabbos) { - this.mutedHabbos.clear(); + synchronized (getRoomInfractionManager().getMutedHabbos()) { + getRoomInfractionManager().getMutedHabbos().clear(); } for (InteractionGameTimer timer : this.getRoomSpecialTypes().getGameTimers().values()) { @@ -609,7 +497,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.games.clear(); - this.roomUnitManager.removeAllPetsExceptRoomOwner(); + this.roomUnitManager.getRoomPetManager().removeAllPetsExceptRoomOwner(); this.roomItemManager.dispose(); @@ -623,19 +511,16 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomUnitManager.dispose(); } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } } try { - this.wordQuiz = ""; - this.yesVotes = 0; - this.noVotes = 0; this.updateDatabaseUserCount(); this.preLoaded = true; this.layout = null; } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } } @@ -677,55 +562,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.needsUpdate = true; } - public String[] filterAnything() { - return new String[]{this.roomInfo.getOwnerInfo().getUsername(), this.roomInfo.getGuildName(), this.roomInfo.getDescription(), this.getPromotionDesc()}; - } - - public boolean isPromoted() { - this.roomInfo.setPromoted(this.promotion != null && this.promotion.getEndTimestamp() > Emulator.getIntUnixTimestamp()); - this.needsUpdate = true; - return this.roomInfo.isPromoted(); - } - - public String getPromotionDesc() { - if (this.promotion != null) { - return this.promotion.getDescription(); - } - - return ""; - } - - public void createPromotion(String title, String description, int category) { - this.roomInfo.setPromoted(true); - - if (this.promotion == null) { - this.promotion = new RoomPromotion(this, title, description, Emulator.getIntUnixTimestamp() + (120 * 60), Emulator.getIntUnixTimestamp(), category); - } else { - this.promotion.setTitle(title); - this.promotion.setDescription(description); - this.promotion.setEndTimestamp(Emulator.getIntUnixTimestamp() + (120 * 60)); - this.promotion.setCategory(category); - } - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp, start_timestamp, category) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?, category = ?")) { - statement.setInt(1, this.roomInfo.getId()); - statement.setString(2, title); - statement.setString(3, description); - statement.setInt(4, this.promotion.getEndTimestamp()); - statement.setInt(5, this.promotion.getStartTimestamp()); - statement.setInt(6, category); - statement.setString(7, this.promotion.getTitle()); - statement.setString(8, this.promotion.getDescription()); - statement.setInt(9, this.promotion.getEndTimestamp()); - statement.setInt(10, this.promotion.getCategory()); - statement.execute(); - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - - this.needsUpdate = true; - } - public boolean addGame(Game game) { synchronized (this.games) { return this.games.add(game); @@ -786,7 +622,7 @@ public class Room implements Comparable, ISerialize, Runnable { return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null; } } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } return true; @@ -824,25 +660,13 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getBotsOnItem(RoomItem item) { THashSet bots = new THashSet<>(); - for (short x = item.getCurrentPosition().getX(); x < item.getCurrentPosition().getX() + item.getBaseItem().getLength(); x++) { - for (short y = item.getCurrentPosition().getY(); y < item.getCurrentPosition().getY() + item.getBaseItem().getWidth(); y++) { - RoomTile tile = this.layout.getTile(x, y); - bots.addAll(this.roomUnitManager.getRoomBotManager().getBotsAt(tile)); - } - } - + bots.addAll(this.roomUnitManager.getRoomBotManager().getBotsOnItem(item)); return bots; } public THashSet getPetsOnItem(RoomItem item) { THashSet pets = new THashSet<>(); - for (short x = item.getCurrentPosition().getX(); x < item.getCurrentPosition().getX() + item.getBaseItem().getLength(); x++) { - for (short y = item.getCurrentPosition().getY(); y < item.getCurrentPosition().getY() + item.getBaseItem().getWidth(); y++) { - RoomTile tile = this.layout.getTile(x, y); - pets.addAll(this.roomUnitManager.getPetsAt(tile)); - } - } - + pets.addAll(this.roomUnitManager.getRoomPetManager().getPetsOnItem(item)); return pets; } @@ -861,39 +685,13 @@ public class Room implements Comparable, ISerialize, Runnable { roomUnit.setLocation(tile); roomUnit.walkTo(tile); roomUnit.setCurrentZ(z); - this.updateRoomUnit(roomUnit); - - + roomUnitManager.updateRoomUnit(roomUnit); } } - public void muteHabbo(Habbo habbo, int minutes) { - synchronized (this.mutedHabbos) { - this.mutedHabbos.put(habbo.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + (minutes * 60)); - } - } - - public boolean isMuted(Habbo habbo) { - if (this.getRoomInfo().isRoomOwner(habbo) || this.roomRightsManager.hasRights(habbo)) - return false; - - if (this.mutedHabbos.containsKey(habbo.getHabboInfo().getId())) { - boolean time = this.mutedHabbos.get(habbo.getHabboInfo().getId()) > Emulator.getIntUnixTimestamp(); - - if (!time) { - this.mutedHabbos.remove(habbo.getHabboInfo().getId()); - } - - return time; - } - - return false; - } - public void habboEntered(Habbo habbo) { synchronized (this.roomUnitManager.getRoomBotManager().getCurrentBots()) { - if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) - return; + if (habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) return; Iterator botIterator = this.roomUnitManager.getRoomBotManager().getCurrentBots().values().iterator(); @@ -916,331 +714,55 @@ public class Room implements Comparable, ISerialize, Runnable { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); + log.error(RoomConfiguration.CAUGHT_EXCEPTION, e); } } } - public void floodMuteHabbo(Habbo habbo, int timeOut) { - habbo.getHabboStats().setMutedCount(habbo.getHabboStats().getMutedCount() + 1); - timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().getMutedCount(), 2))); - habbo.getHabboStats().getChatCounter().set(0); - habbo.mute(timeOut, true); - } - - public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) { - this.talk(habbo, roomChatMessage, chatType, false); - } - - public void talk(final Habbo habbo, final RoomChatMessage roomChatMessage, RoomChatType chatType, boolean ignoreWired) { - if (!habbo.getHabboStats().allowTalk()) - return; - - if (habbo.getRoomUnit().isInvisible() && Emulator.getConfig().getBoolean("invisible.prevent.chat", false)) { - if (!Emulator.getGameEnvironment().getCommandsManager().handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { - habbo.whisper(Emulator.getTexts().getValue("invisible.prevent.chat.error")); - } - - return; - } - - if (habbo.getRoomUnit().getRoom() != this) - return; - - long millis = System.currentTimeMillis(); - if (HABBO_CHAT_DELAY && millis - habbo.getHabboStats().getLastChat() < 750) { - return; - } - - habbo.getHabboStats().setLastChat(millis); - if (roomChatMessage != null && Emulator.getConfig().getBoolean("easter_eggs.enabled") && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { - habbo.getHabboStats().getChatCounter().addAndGet(1); - Emulator.getThreading().run(new YouAreAPirate(habbo, this)); - return; - } - - UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.TALKED, false); - Emulator.getPluginManager().fireEvent(event); - - if (!event.isCancelled() && !event.isIdle()) { - habbo.getRoomUnit().unIdle(); - } - - this.sendComposer(new UserTypingMessageComposer(habbo.getRoomUnit(), false).compose()); - - if (roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().equals("")) - return; - - if (!habbo.hasPermissionRight(Permission.ACC_NOMUTE) && (!MUTEAREA_CAN_WHISPER || chatType != RoomChatType.WHISPER)) { - for (RoomItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) { - if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentPosition())) { - return; - } - } - } - - if (!this.roomWordFilterManager.getFilteredWords().isEmpty() && !habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { - for (String string : this.roomWordFilterManager.getFilteredWords()) { - roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba")); - } - } - - if (!habbo.hasPermissionRight(Permission.ACC_NOMUTE)) { - if (this.isMuted() && !this.roomRightsManager.hasRights(habbo)) { - return; - } - - if (this.isMuted(habbo)) { - habbo.getClient().sendResponse(new RemainingMutePeriodComposer(this.mutedHabbos.get(habbo.getHabboInfo().getId()) - Emulator.getIntUnixTimestamp())); - return; - } - } - - if (chatType != RoomChatType.WHISPER) { - if (Emulator.getGameEnvironment().getCommandsManager().handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { - WiredHandler.handle(WiredTriggerType.SAY_COMMAND, habbo.getRoomUnit(), habbo.getRoomUnit().getRoom(), new Object[]{roomChatMessage.getMessage()}); - roomChatMessage.isCommand = true; - return; - } - - if (!ignoreWired) { - if (WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, habbo.getRoomUnit(), habbo.getRoomUnit().getRoom(), new Object[]{roomChatMessage.getMessage()})) { - habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(roomChatMessage.getMessage(), habbo, habbo, roomChatMessage.getBubble()))); - return; - } - } - } - - if (!habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FLOOD)) { - final int chatCounter = habbo.getHabboStats().getChatCounter().addAndGet(1); - - if (chatCounter > 3) { - final boolean floodRights = Emulator.getConfig().getBoolean("flood.with.rights"); - final boolean hasRights = this.roomRightsManager.hasRights(habbo); - - if (floodRights || !hasRights) { - if (this.roomInfo.getChatProtection() == 0 || (this.roomInfo.getChatProtection() == 1 && chatCounter > 4) || (this.roomInfo.getChatProtection() == 2 && chatCounter > 5)) { - this.floodMuteHabbo(habbo, muteTime); - return; - } - } - } - } - - ServerMessage prefixMessage = null; - - if (Emulator.getPluginManager().isRegistered(UsernameTalkEvent.class, true)) { - UsernameTalkEvent usernameTalkEvent = Emulator.getPluginManager().fireEvent(new UsernameTalkEvent(habbo, roomChatMessage, chatType)); - if (usernameTalkEvent.hasCustomComposer()) { - prefixMessage = usernameTalkEvent.getCustomComposer(); - } - } - - if (prefixMessage == null) { - prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getPermissionGroup().hasPrefix() ? new UserNameChangedMessageComposer(habbo, true).compose() : null; - } - ServerMessage clearPrefixMessage = prefixMessage != null ? new UserNameChangedMessageComposer(habbo).compose() : null; - - Rectangle tentRectangle = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentPosition()); - - String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$", ""); - - if (trimmedMessage.isEmpty()) trimmedMessage = " "; - - roomChatMessage.setMessage(trimmedMessage); - - if (chatType == RoomChatType.WHISPER) { - if (roomChatMessage.getTargetHabbo() == null) { - return; - } - - RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); - staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage()); - - final ServerMessage message = new WhisperMessageComposer(roomChatMessage).compose(); - final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); - - for (Habbo h : this.roomUnitManager.getCurrentHabbos().values()) { - if (h == roomChatMessage.getTargetHabbo() || h == habbo) { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { - if (prefixMessage != null) { - h.getClient().sendResponse(prefixMessage); - } - h.getClient().sendResponse(message); - - if (clearPrefixMessage != null) { - h.getClient().sendResponse(clearPrefixMessage); - } - } - - continue; - } - if (h.hasPermissionRight(Permission.ACC_SEE_WHISPERS)) { - h.getClient().sendResponse(staffMessage); - } - } - } else if (chatType == RoomChatType.TALK) { - ServerMessage message = new ChatMessageComposer(roomChatMessage).compose(); - boolean noChatLimit = habbo.hasPermissionRight(Permission.ACC_CHAT_NO_LIMIT); - - for (Habbo h : this.roomUnitManager.getCurrentHabbos().values()) { - if ((h.getRoomUnit().getCurrentPosition().distance(habbo.getRoomUnit().getCurrentPosition()) <= this.roomInfo.getChatDistance() || - h.equals(habbo) || - this.roomRightsManager.hasRights(h) || - noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { - if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { - h.getClient().sendResponse(prefixMessage); - } - h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().isPreferOldChat()) { - h.getClient().sendResponse(clearPrefixMessage); - } - } - continue; - } - // Staff should be able to see the tent chat anyhow - showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle); - } - } else if (chatType == RoomChatType.SHOUT) { - ServerMessage message = new ShoutMessageComposer(roomChatMessage).compose(); - - for (Habbo h : this.roomUnitManager.getCurrentHabbos().values()) { - // Show the message - // If the receiving Habbo has not ignored the sending Habbo - // AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { - if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { - h.getClient().sendResponse(prefixMessage); - } - h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().isPreferOldChat()) { - h.getClient().sendResponse(clearPrefixMessage); - } - continue; - } - // Staff should be able to see the tent chat anyhow, even when not in the same tent - showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle); - } - } - - if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) { - synchronized (this.roomUnitManager.getRoomBotManager().getCurrentBots()) { - Iterator botIterator = this.roomUnitManager.getRoomBotManager().getCurrentBots().values().iterator(); - - while (botIterator.hasNext()) { - try { - Bot bot = botIterator.next(); - bot.onUserSay(roomChatMessage); - - } catch (NoSuchElementException e) { - log.error(CAUGHT_EXCEPTION, e); - break; - } - } - } - - if (roomChatMessage.getBubble().triggersTalkingFurniture()) { - THashSet items = this.roomSpecialTypes.getItemsOfType(InteractionTalkingFurniture.class); - - for (RoomItem item : items) { - if (this.layout.getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()).distance(habbo.getRoomUnit().getCurrentPosition()) <= Emulator.getConfig().getInt("furniture.talking.range")) { - int count = Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.count", 0); - - if (count > 0) { - int randomValue = Emulator.getRandom().nextInt(count + 1); - - RoomChatMessage itemMessage = new RoomChatMessage(Emulator.getTexts().getValue(item.getBaseItem().getName() + ".message." + randomValue, item.getBaseItem().getName() + ".message." + randomValue + " not found!"), habbo, RoomChatMessageBubbles.getBubble(Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.bubble", RoomChatMessageBubbles.PARROT.getType()))); - - this.sendComposer(new ChatMessageComposer(itemMessage).compose()); - - try { - item.onClick(habbo.getClient(), this, new Object[0]); - item.setExtraData("1"); - updateItemState(item); - - Emulator.getThreading().run(() -> { - item.setExtraData("0"); - updateItemState(item); - }, 2000); - - break; - } catch (Exception e) { - log.error(CAUGHT_EXCEPTION, e); - } - } - } - } - } - } - } - - /** - * Sends the given message to the receiving Habbo if the Habbo has the ACC_SEE_TENTCHAT permission and is not within the tent - * - * @param receivingHabbo The receiving Habbo - * @param roomChatMessage The message to receive - * @param tentRectangle The whole tent area from where the sending Habbo is saying something - */ - private void showTentChatMessageOutsideTentIfPermitted(Habbo receivingHabbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle) { - if (receivingHabbo != null && receivingHabbo.hasPermissionRight(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentPosition())) { - RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); - staffChatMessage.setMessage("[" + Emulator.getTexts().getValue("hotel.room.tent.prefix") + "] " + staffChatMessage.getMessage()); - final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); - receivingHabbo.getClient().sendResponse(staffMessage); - } - } - public THashSet getLockedTiles() { THashSet lockedTiles = new THashSet<>(); - Iterator iterator = this.roomItemManager.getCurrentItems().values().iterator(); - - for (int i = this.roomItemManager.getCurrentItems().size(); i-- > 0; ) { + for (int itemsCount = this.roomItemManager.getCurrentItems().size(); itemsCount-- > 0; ) { RoomItem item; try { item = iterator.next(); } catch (Exception e) { break; } - - if (item.getBaseItem().getType() != FurnitureType.FLOOR) - continue; - + if (item.getBaseItem().getType() != FurnitureType.FLOOR) continue; boolean found = lockedTiles.stream().anyMatch(tile -> tile.getX() == item.getCurrentPosition().getX() && tile.getY() == item.getCurrentPosition().getY()); - if (!found) { - if (item.getRotation() == 0 || item.getRotation() == 4) { - for (short y = 0; y < item.getBaseItem().getLength(); y++) { - for (short x = 0; x < item.getBaseItem().getWidth(); x++) { - RoomTile tile = this.layout.getTile((short) (item.getCurrentPosition().getX() + x), (short) (item.getCurrentPosition().getY() + y)); - - if (tile != null) { - lockedTiles.add(tile); - } - } - } - } else { - for (short y = 0; y < item.getBaseItem().getWidth(); y++) { - for (short x = 0; x < item.getBaseItem().getLength(); x++) { - RoomTile tile = this.layout.getTile((short) (item.getCurrentPosition().getX() + x), (short) (item.getCurrentPosition().getY() + y)); - - if (tile != null) { - lockedTiles.add(tile); - } - } - } - } + addLockedTiles(lockedTiles, item); } } - return lockedTiles; } + private void addLockedTiles(THashSet lockedTiles, RoomItem item) { + short length; + short width; + + if (item.getRotation() == 0 || item.getRotation() == 4) { + length = item.getBaseItem().getLength(); + width = item.getBaseItem().getWidth(); + } else { + width = item.getBaseItem().getLength(); + length = item.getBaseItem().getWidth(); + } + + for (short y = 0; y < length; y++) { + for (short x = 0; x < width; x++) { + RoomTile tile = this.layout.getTile((short) (item.getCurrentPosition().getX() + x), (short) (item.getCurrentPosition().getY() + y)); + if (tile != null) { + lockedTiles.add(tile); + } + } + } + } + public double getStackHeight(short x, short y, boolean calculateHeightmap, RoomItem exclude) { - if (x < 0 || y < 0 || this.layout == null) - return calculateHeightmap ? Short.MAX_VALUE : 0.0; + if (x < 0 || y < 0 || this.layout == null) return calculateHeightmap ? Short.MAX_VALUE : 0.0; if (Emulator.getPluginManager().isRegistered(FurnitureStackHeightEvent.class, true)) { FurnitureStackHeightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureStackHeightEvent(x, y, this)); @@ -1283,13 +805,10 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean canSitOrLayAt(RoomTile tile) { - if (tile == null) { + if (tile == null || this.roomUnitManager.hasHabbosAt(tile)) { return false; } - if (this.roomUnitManager.hasHabbosAt(tile)) - return false; - THashSet items = this.roomItemManager.getItemsAt(tile); return this.canSitAt(items) || this.canLayAt(items); @@ -1302,50 +821,36 @@ public class Room implements Comparable, ISerialize, Runnable { return false; } - if (this.roomUnitManager.hasHabbosAt(tile)) - return false; + if (this.roomUnitManager.hasHabbosAt(tile)) return false; return this.canSitAt(this.roomItemManager.getItemsAt(tile)); } boolean canSitAt(THashSet items) { - if (items == null) - return false; - + if (items == null) return false; RoomItem tallestItem = null; - + double tallestItemHeight = 0; for (RoomItem item : items) { - if (tallestItem != null) { - if (tallestItem.getCurrentZ() + Item.getCurrentHeight(tallestItem) > item.getCurrentZ() + Item.getCurrentHeight(item)) - continue; + double currentItemHeight = item.getCurrentZ() + Item.getCurrentHeight(item); + if (tallestItem == null || tallestItemHeight <= currentItemHeight) { + tallestItem = item; + tallestItemHeight = currentItemHeight; } - - tallestItem = item; } - - if (tallestItem == null) - return false; - - return tallestItem.getBaseItem().allowSit(); + return tallestItem != null && tallestItem.getBaseItem().allowSit(); } public boolean canLayAt(RoomTile tile) { return this.canLayAt(this.roomItemManager.getItemsAt(tile)); } - boolean canLayAt(THashSet items) { - if (items == null || items.isEmpty()) - return true; + boolean canLayAt(Set roomItems) { + if (roomItems == null || roomItems.isEmpty()) return true; - RoomItem topItem = null; + RoomItem topItem = roomItems.iterator().next(); + topItem = roomItems.stream().filter(Objects::nonNull).max(Comparator.comparingDouble(RoomItem::getCurrentZ)).orElse(topItem); - for (RoomItem item : items) { - if ((topItem == null || item.getCurrentZ() > topItem.getCurrentZ())) { - topItem = item; - } - } - - return (topItem == null || topItem.getBaseItem().allowLay()); + return topItem.getBaseItem().allowLay(); } public RoomTile getRandomWalkableTile() { @@ -1373,8 +878,7 @@ public class Room implements Comparable, ISerialize, Runnable { public void petChat(ServerMessage message) { for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { - if (!habbo.getHabboStats().isIgnorePets()) - habbo.getClient().sendResponse(message); + if (!habbo.getHabboStats().isIgnorePets()) habbo.getClient().sendResponse(message); } } @@ -1387,29 +891,10 @@ public class Room implements Comparable, ISerialize, Runnable { if (habbo == null) { return; } - if (!habbo.getHabboStats().isIgnoreBots()) - habbo.getClient().sendResponse(message); + if (!habbo.getHabboStats().isIgnoreBots()) habbo.getClient().sendResponse(message); } } - private void loadBans(Connection connection) { - this.bannedHabbos.clear(); - - try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) { - statement.setInt(1, Emulator.getIntUnixTimestamp()); - statement.setInt(2, this.roomInfo.getId()); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - if (this.bannedHabbos.containsKey(set.getInt(DatabaseConstants.USER_ID))) - continue; - - this.bannedHabbos.put(set.getInt(DatabaseConstants.USER_ID), new RoomBan(set)); - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } - } public RoomRightLevels getGuildRightLevel(Habbo habbo) { if (!this.roomInfo.hasGuild()) { @@ -1428,36 +913,6 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomRightLevels.NONE; } - public void unbanHabbo(int userId) { - RoomBan ban = this.bannedHabbos.remove(userId); - - if (ban != null) { - ban.delete(); - } - - this.sendComposer(new UserUnbannedFromRoomComposer(this, userId).compose()); - } - - public boolean isBanned(Habbo habbo) { - RoomBan ban = this.bannedHabbos.get(habbo.getHabboInfo().getId()); - - boolean banned = ban != null && ban.getEndTimestamp() > Emulator.getIntUnixTimestamp() && !habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM); - - if (!banned && ban != null) { - this.unbanHabbo(habbo.getHabboInfo().getId()); - } - - return banned; - } - - public TIntObjectHashMap getBannedHabbos() { - return this.bannedHabbos; - } - - public void addRoomBan(RoomBan roomBan) { - this.bannedHabbos.put(roomBan.getUserId(), roomBan); - } - public void updateItem(RoomItem item) { if (!this.isLoaded()) { return; @@ -1529,7 +984,6 @@ public class Room implements Comparable, ISerialize, Runnable { for (int i = this.roomItemManager.getCurrentItems().size(); i-- > 0; ) { RoomItem roomItem = iterator.next(); - if (roomItem instanceof InteractionGuildFurni interactionGuildFurni && interactionGuildFurni.getGuildId() == guild.getId()) { this.updateItem(roomItem); } @@ -1539,45 +993,8 @@ public class Room implements Comparable, ISerialize, Runnable { public void refreshGuildRightsInRoom() { for (Habbo habbo : this.roomUnitManager.getCurrentHabbos().values()) { - if ((habbo.getRoomUnit().getRoom() == this && habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) - && (!(habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_MOVEROTATE)))) + if ((habbo.getRoomUnit().getRoom() == this && habbo.getHabboInfo().getId() != this.roomInfo.getOwnerInfo().getId()) && (!(habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) || habbo.hasPermissionRight(Permission.ACC_MOVEROTATE)))) this.getRoomRightsManager().refreshRightsForHabbo(habbo); } } - - public void handleWordQuiz(Habbo habbo, String answer) { - synchronized (this.userVotes) { - if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) { - answer = answer.replace(":", ""); - - if (answer.equals("0")) { - this.noVotes++; - } else if (answer.equals("1")) { - this.yesVotes++; - } - - this.sendComposer(new QuestionAnsweredComposer(habbo.getHabboInfo().getId(), answer, this.noVotes, this.yesVotes).compose()); - this.userVotes.add(habbo.getHabboInfo().getId()); - } - } - } - - public void startWordQuiz(String question, int duration) { - if (!this.hasActiveWordQuiz()) { - this.wordQuiz = question; - this.noVotes = 0; - this.yesVotes = 0; - this.userVotes.clear(); - this.wordQuizEnd = Emulator.getIntUnixTimestamp() + (duration / 1000); - this.sendComposer(new QuestionComposer(duration, question).compose()); - } - } - - public boolean hasActiveWordQuiz() { - return Emulator.getIntUnixTimestamp() < this.wordQuizEnd; - } - - public boolean hasVotedInWordQuiz(Habbo habbo) { - return this.userVotes.contains(habbo.getHabboInfo().getId()); - } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index c86e220b..d218ffc3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -22,10 +22,12 @@ import com.eu.habbo.habbohotel.pets.PetData; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.habbohotel.polls.PollManager; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.constants.RoomRightLevels; import com.eu.habbo.habbohotel.rooms.constants.RoomState; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.infractions.RoomBan; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; @@ -38,8 +40,6 @@ import com.eu.habbo.messages.incoming.users.NewUserExperienceScriptProceedEvent; import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer; import com.eu.habbo.messages.outgoing.hotelview.CloseConnectionMessageComposer; import com.eu.habbo.messages.outgoing.polls.PollOfferComposer; -import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; -import com.eu.habbo.messages.outgoing.polls.infobus.QuestionFinishedComposer; import com.eu.habbo.messages.outgoing.rooms.*; import com.eu.habbo.messages.outgoing.rooms.items.ItemsComposer; import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer; @@ -216,7 +216,7 @@ public class RoomManager { public List getRoomsByScore() { List rooms = new ArrayList<>(this.activeRooms.values()); - rooms.sort(Room.SORT_SCORE); + rooms.sort(RoomConfiguration.SORT_SCORE); return rooms; } @@ -240,7 +240,7 @@ public class RoomManager { } } - rooms.sort(Room.SORT_ID); + rooms.sort(RoomConfiguration.SORT_ID); return rooms; } @@ -489,7 +489,7 @@ public class RoomManager { } //If Habbo is banned AND doesn't have Permissions can't enter to room - if (room.isBanned(habbo) && !room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM)) { + if (room.getRoomInfractionManager().isBanned(habbo) && !room.getRoomInfo().isRoomOwner(habbo) && !habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM)) { habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED)); return; } @@ -542,8 +542,7 @@ public class RoomManager { } else if (room.getRoomInfo().getState() == RoomState.PASSWORD) { if (room.getRoomInfo().getPassword().equalsIgnoreCase(password)) { this.openRoom(habbo, room, spawnLocation); - } - else { + } else { habbo.getClient().sendResponse(new GenericErrorComposer(GenericErrorComposer.WRONG_PASSWORD_USED)); habbo.getClient().sendResponse(new CloseConnectionMessageComposer()); habbo.getRoomUnit().setLoadingRoom(null); @@ -582,12 +581,12 @@ public class RoomManager { RoomTile spawnTile = spawnLocation == null ? room.getLayout().getDoorTile() : spawnLocation; RoomRotation spawnDirection = RoomRotation.values()[room.getLayout().getDoorDirection()]; - if(spawnLocation != null) { + if (spawnLocation != null) { roomHabbo.setCanLeaveRoomByDoor(false); roomHabbo.setTeleporting(true); RoomItem topItem = room.getRoomItemManager().getTopItemAt(spawnLocation); - if(topItem != null) { + if (topItem != null) { spawnDirection = RoomRotation.values()[topItem.getRotation()]; } } @@ -624,8 +623,8 @@ public class RoomManager { roomHabbo.setCmdFastWalkEnabled(roomHabbo.isCmdFastWalkEnabled() && habbo.canExecuteCommand("cmd_fastwalk", room.getRoomRightsManager().hasRights(habbo))); - if (room.isPromoted()) { - habbo.getClient().sendResponse(new RoomEventComposer(room, room.getPromotion())); + if (room.getRoomInfo().isPromoted()) { + habbo.getClient().sendResponse(new RoomEventComposer(room, room.getRoomPromotionManager().getPromotion())); } else { habbo.getClient().sendResponse(new RoomEventComposer(null, null)); } @@ -755,9 +754,9 @@ public class RoomManager { habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems)); floorItems.clear(); - if (!room.getRoomUnitManager().getCurrentPets().isEmpty()) { - habbo.getClient().sendResponse(new RoomPetComposer(room.getRoomUnitManager().getCurrentPets())); - room.getRoomUnitManager().getCurrentPets().values().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()))); + if (!room.getRoomUnitManager().getRoomPetManager().getCurrentPets().isEmpty()) { + habbo.getClient().sendResponse(new RoomPetComposer(room.getRoomUnitManager().getRoomPetManager().getCurrentPets())); + room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()))); } if (!habbo.getHabboStats().allowTalk()) { @@ -837,13 +836,7 @@ public class RoomManager { } } - if (room.hasActiveWordQuiz()) { - habbo.getClient().sendResponse(new QuestionComposer((Emulator.getIntUnixTimestamp() - room.getWordQuizEnd()) * 1000, room.getWordQuiz())); - - if (room.hasVotedInWordQuiz(habbo)) { - habbo.getClient().sendResponse(new QuestionFinishedComposer(room.getNoVotes(), room.getYesVotes())); - } - } + room.getRoomWordQuizManager().onHabboEntered(habbo); WiredHandler.handle(WiredTriggerType.ENTER_ROOM, habbo.getRoomUnit(), room, null); room.habboEntered(habbo); @@ -855,6 +848,7 @@ public class RoomManager { } } + void logEnter(Habbo habbo, Room room) { habbo.getHabboStats().roomEnterTimestamp = Emulator.getIntUnixTimestamp(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_enter_log (room_id, user_id, timestamp) VALUES(?, ?, ?)")) { @@ -938,7 +932,7 @@ public class RoomManager { } public ArrayList getPublicRooms() { - return this.activeRooms.values().stream().filter(room -> room.getRoomInfo().isPublicRoom()).sorted(Room.SORT_ID) .collect(Collectors.toCollection(ArrayList::new)); + return this.activeRooms.values().stream().filter(room -> room.getRoomInfo().isPublicRoom()).sorted(RoomConfiguration.SORT_ID).collect(Collectors.toCollection(ArrayList::new)); } public ArrayList getPopularRooms(int count) { @@ -1279,7 +1273,8 @@ public class RoomManager { } public ArrayList getRoomsPromoted() { - return activeRooms.values().stream().filter(Room::isPromoted).collect(Collectors.toCollection(ArrayList::new)); } + return activeRooms.values().stream().filter(r -> r.getRoomInfo().isPromoted()).collect(Collectors.toCollection(ArrayList::new)); + } public ArrayList getRoomsStaffPromoted() { return activeRooms.values().stream().filter(room -> room.getRoomInfo().isStaffPicked()).collect(Collectors.toCollection(ArrayList::new)); @@ -1384,7 +1379,7 @@ public class RoomManager { RoomBan roomBan = new RoomBan(roomId, userId, name, Emulator.getIntUnixTimestamp() + length.duration); roomBan.insert(); - room.addRoomBan(roomBan); + room.getRoomInfractionManager().addRoomBan(roomBan); if (habbo != null && habbo.getRoomUnit().getRoom() == room) { room.getRoomUnitManager().removeHabbo(habbo, true); @@ -1393,9 +1388,9 @@ public class RoomManager { } public void handleSpawnLocation(RoomHabbo roomHabbo, RoomTile location, RoomRotation direction) { - roomHabbo.setLocation(location); - roomHabbo.setCurrentZ(location.getStackHeight()); - roomHabbo.setRotation(direction); + roomHabbo.setLocation(location); + roomHabbo.setCurrentZ(location.getStackHeight()); + roomHabbo.setRotation(direction); } public void registerGameType(Class gameClass) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java index 87f7fe95..91071766 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitManager.java @@ -8,9 +8,9 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionGate; import com.eu.habbo.habbohotel.items.interactions.InteractionPyramid; import com.eu.habbo.habbohotel.items.interactions.InteractionRoller; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.bots.RoomBotManager; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.constants.RoomRightLevels; import com.eu.habbo.habbohotel.rooms.constants.RoomTileState; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; @@ -18,15 +18,15 @@ import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; +import com.eu.habbo.habbohotel.rooms.pets.RoomPetManager; +import com.eu.habbo.habbohotel.rooms.pets.entities.RoomPet; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; +import com.eu.habbo.habbohotel.rooms.types.IRoomManager; import com.eu.habbo.habbohotel.units.Unit; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; -import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; -import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.users.IgnoreResultMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer; @@ -40,87 +40,49 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; -import static com.eu.habbo.habbohotel.rooms.Room.CAUGHT_EXCEPTION; +import static com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration.CAUGHT_EXCEPTION; import static com.eu.habbo.habbohotel.rooms.utils.cycle.CycleFunctions.cycleIdle; @Slf4j @Getter -public class RoomUnitManager { - private final Room room; +public class RoomUnitManager extends IRoomManager { private final ConcurrentHashMap currentRoomUnits; private final ConcurrentHashMap currentHabbos; - private final ConcurrentHashMap currentPets; private volatile int roomUnitCounter; public final Object roomUnitLock; private final RoomBotManager roomBotManager; + private final RoomPetManager roomPetManager; private int roomIdleCycles; - @Setter private long rollerCycle = System.currentTimeMillis(); public RoomUnitManager(Room room) { - this.room = room; + super(room); this.currentRoomUnits = new ConcurrentHashMap<>(); this.currentHabbos = new ConcurrentHashMap<>(); - this.currentPets = new ConcurrentHashMap<>(); this.roomUnitCounter = 0; this.roomUnitLock = new Object(); roomBotManager = new RoomBotManager(this); + roomPetManager = new RoomPetManager(this); } public synchronized void load(Connection connection) { this.roomIdleCycles = 0; roomBotManager.loadBots(connection); - this.loadPets(connection); + roomPetManager.loadPets(connection); } - - private synchronized void loadPets(Connection connection) { - this.currentPets.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.room.getRoomInfo().getId()); - try (ResultSet set = statement.executeQuery()) { - while (set.next()) { - Pet pet = PetManager.loadPet(set); - - pet.setRoom(this.room); - 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(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")]); - } - pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); - pet.getRoomUnit().setCanWalk(true); - this.addRoomUnit(pet); - this.room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); - } - } - } catch (SQLException e) { - log.error(CAUGHT_SQL_EXCEPTION, e); - } catch (Exception e) { - log.error("Caught Exception", e); - } - } - public void addRoomUnit(Unit unit) { synchronized (this.roomUnitLock) { //TODO Maybe set the room in this method @@ -135,10 +97,10 @@ public class RoomUnitManager { unit.getRoomUnit().getRoom().updateDatabaseUserCount(); } case BOT -> { - roomBotManager.addBot((Bot)unit); + roomBotManager.addBot((Bot) unit); } case PET -> { - this.currentPets.put(((Pet) unit).getId(), (Pet) unit); + roomPetManager.addPet((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()); @@ -157,10 +119,10 @@ public class RoomUnitManager { } public boolean areRoomUnitsAt(RoomTile tile, RoomUnit skippedRoomUnit) { - if(skippedRoomUnit == null) { + if (skippedRoomUnit == null) { return this.areRoomUnitsAt(tile); } - + return this.currentRoomUnits.values().stream().filter(roomUnit -> !roomUnit.equals(skippedRoomUnit)).anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile)); } @@ -199,7 +161,7 @@ public class RoomUnitManager { public void updateHabbosAt(RoomTile tile) { Collection habbos = this.getHabbosAt(tile); - if(habbos == null || habbos.isEmpty()) { + if (habbos == null || habbos.isEmpty()) { return; } @@ -217,9 +179,9 @@ public class RoomUnitManager { } if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) { - if(item.getBaseItem().allowSit()) { + if (item.getBaseItem().allowSit()) { habbo.getRoomUnit().addStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(item))); - } else if(item.getBaseItem().allowLay()) { + } else if (item.getBaseItem().allowLay()) { habbo.getRoomUnit().addStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(item))); } @@ -232,81 +194,14 @@ public class RoomUnitManager { } - - - - public void placePet(Pet pet, Room room, short x, short y, double z) { - synchronized (this.currentPets) { - RoomTile spawnTile = room.getLayout().getTile(x, y); - - if (spawnTile == null) { - spawnTile = room.getLayout().getDoorTile(); - } - - pet.setRoom(room); - pet.getRoomUnit().walkTo(spawnTile); - pet.getRoomUnit().setLocation(spawnTile) - .setRoomUnitType(RoomUnitType.PET) - .setCanWalk(true) - .setCurrentZ(z); - - if (pet.getRoomUnit().getCurrentPosition() == null) { - pet.getRoomUnit() - .setLocation(room.getLayout().getDoorTile()) - .setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection())); - } - - pet.setSqlUpdateNeeded(true); - room.getFurniOwnerNames().put(pet.getUserId(), this.getRoomHabboById(pet.getUserId()).getHabboInfo().getUsername()); - this.addRoomUnit(pet); - room.sendComposer(new RoomPetComposer(pet).compose()); - } - } - - public boolean hasPetsAt(RoomTile tile) { - return this.currentPets.values().stream().anyMatch(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)); - } - - public Collection getPetsAt(RoomTile tile) { - return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); - } - - public Pet getRoomPetById(int petId) { - return this.currentPets.get(petId); - } - - public Pet getPetByRoomUnit(RoomUnit roomUnit) { - return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit() == roomUnit).findFirst().orElse(null); - } - - public void pickUpMyPets(Habbo owner) { - THashSet pets = new THashSet<>(); - - synchronized (this.currentPets) { - for (Pet pet : this.currentPets.values()) { - if (pet.getUserId() == owner.getHabboInfo().getId()) { - pets.add(pet); - } - } - } - - for (Pet pet : pets) { - pet.removeFromRoom(); - Emulator.getThreading().run(pet); - owner.getInventory().getPetsComponent().addPet(pet); - owner.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); - this.currentPets.remove(pet.getId()); - } - } - public void removeHabbo(Habbo habbo, boolean sendRemovePacket) { - if(!this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { + if (!this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { return; } RoomHabbo roomHabbo = habbo.getRoomUnit(); - if(roomHabbo.getCurrentPosition() != null) { + if (roomHabbo.getCurrentPosition() != null) { roomHabbo.getCurrentPosition().removeUnit(habbo.getRoomUnit()); } @@ -315,7 +210,7 @@ public class RoomUnitManager { removeUnit(roomHabbo.getVirtualId()); } - roomHabbo.getRoom().sendComposer(new UserRemoveMessageComposer(roomHabbo).compose()); + sendComposer(new UserRemoveMessageComposer(roomHabbo).compose()); //MOVE THIS TO RoomTile.java -> removeUnit() RoomItem item = roomHabbo.getRoom().getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition()); @@ -332,97 +227,38 @@ public class RoomUnitManager { roomHabbo.getRoom().getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); } - RoomTrade trade = roomHabbo.getRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = roomHabbo.getRoom().getRoomTradeManager().getActiveTradeForHabbo(habbo); if (trade != null) { trade.stopTrade(habbo); } if (!roomHabbo.getRoom().getRoomInfo().isRoomOwner(habbo)) { - this.pickUpMyPets(habbo); + roomPetManager.pickUpMyPets(habbo); } roomHabbo.getRoom().updateDatabaseUserCount(); roomHabbo.clear(); } - - public Pet removePet(int petId) { - Pet pet = this.currentPets.get(petId); - removeUnit(pet.getRoomUnit().getVirtualId()); - return this.currentPets.remove(petId); - } - - public void removeAllPetsExceptRoomOwner() { - ArrayList toRemovePets = new ArrayList<>(); - ArrayList removedPets = new ArrayList<>(); - synchronized (this.currentPets) { - for (Pet pet : this.currentPets.values()) { - try { - if (pet.getUserId() != pet.getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId()) { - toRemovePets.add(pet); - } - - } catch (NoSuchElementException e) { - log.error("Caught exception", e); - break; - } - } - } - - for (Pet pet : toRemovePets) { - removedPets.add(pet); - - pet.removeFromRoom(); - - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); - if (habbo != null) { - habbo.getInventory().getPetsComponent().addPet(pet); - habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); - } - - pet.setSqlUpdateNeeded(true); - pet.run(); - } - - for (Pet pet : removedPets) { - this.currentPets.remove(pet.getId()); - removeUnit(pet.getRoomUnit().getVirtualId()); - } - } - public void clear() { synchronized (this.roomUnitLock) { this.currentRoomUnits.clear(); this.currentHabbos.clear(); this.roomBotManager.clear(); - this.currentPets.clear(); + this.roomPetManager.clear(); this.roomUnitCounter = 0; } } public void dispose() { - for(Habbo habbo : this.currentHabbos.values()) { + for (Habbo habbo : this.currentHabbos.values()) { Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room, true); } - this.currentHabbos.clear(); - roomBotManager.dispose(); - Iterator petIterator = this.currentPets.values().iterator(); - - while(petIterator.hasNext()) { - try { - Pet pet = petIterator.next(); - pet.setSqlUpdateNeeded(true); - Emulator.getThreading().run(pet); - } catch (NoSuchElementException e) { - log.error("Caught Exception", e); - break; - } - } - - this.currentPets.clear(); + roomBotManager.dispose(); + roomPetManager.dispose(); this.currentRoomUnits.clear(); } @@ -430,7 +266,7 @@ public class RoomUnitManager { this.currentRoomUnits.remove(virtualId); } - public boolean cycle(boolean cycleOdd){ + public boolean cycle(boolean cycleOdd) { boolean foundRightHolder = false; if (!getCurrentHabbos().isEmpty()) { this.roomIdleCycles = 0; @@ -474,7 +310,7 @@ public class RoomUnitManager { if (habbo.getHabboStats().isMutedBubbleTracker() && habbo.getHabboStats().allowTalk()) { habbo.getHabboStats().setMutedBubbleTracker(false); - room.sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.UNIGNORED).compose()); + sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.UNIGNORED).compose()); } // Substract 1 from the chatCounter every odd cycle, which is every (500ms * 2). @@ -484,7 +320,7 @@ public class RoomUnitManager { habbo.getRoomUnit().cycle(); - if(habbo.getRoomUnit().isStatusUpdateNeeded()) { + if (habbo.getRoomUnit().isStatusUpdateNeeded()) { habbo.getRoomUnit().setStatusUpdateNeeded(false); updatedUnit.add(habbo.getRoomUnit()); } @@ -497,30 +333,7 @@ public class RoomUnitManager { } updatedUnit.addAll(roomBotManager.cycle()); - if (!getCurrentPets().isEmpty() && room.isAllowBotsWalk()) { - Iterator petIterator = getCurrentPets().values().iterator(); - while(petIterator.hasNext()) { - final Pet pet; - try { - pet = petIterator.next(); - } catch (Exception e) { - break; - } - - pet.getRoomUnit().cycle(); - pet.cycle(); - - if(pet.getRoomUnit().isStatusUpdateNeeded()) { - pet.getRoomUnit().setStatusUpdateNeeded(false); - updatedUnit.add(pet.getRoomUnit()); - } - - if (pet.getRoomUnit().isWalking() && pet.getRoomUnit().getPath().size() == 1 && pet.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { - pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); - updatedUnit.add(pet.getRoomUnit()); - } - } - } + updatedUnit.addAll(roomPetManager.cycle()); if (room.getRoomInfo().getRollerSpeed() != -1 && this.rollerCycle >= room.getRoomInfo().getRollerSpeed()) { @@ -629,7 +442,7 @@ public class RoomUnitManager { for (RoomUnit roomUnit : getRoomUnitsAt(rollerTile)) { if (roomUnit instanceof RoomPet) { - Pet pet = getPetByRoomUnit(roomUnit); + Pet pet = roomPetManager.getPetByRoomUnit(roomUnit); if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null) { unitsOnTile.remove(roomUnit); } @@ -641,7 +454,7 @@ public class RoomUnitManager { for (RoomUnit roomUnit : unitsOnTile) { if (rolledUnitIds.contains(roomUnit.getVirtualId())) continue; - if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break; + if (usersRolledThisTile.size() >= RoomConfiguration.ROLLERS_MAXIMUM_ROLL_AVATARS) break; if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable())) continue; @@ -701,7 +514,7 @@ public class RoomUnitManager { if (!messages.isEmpty()) { for (MessageComposer message : messages) { - room.sendComposer(message.compose()); + sendComposer(message.compose()); } messages.clear(); } @@ -715,9 +528,7 @@ public class RoomUnitManager { if (newRoller == null || topItem == newRoller) { List sortedItems = new ArrayList<>(itemsOnRoller); - sortedItems.sort((o1, o2) -> { - return Double.compare(o2.getCurrentZ(), o1.getCurrentZ()); - }); + sortedItems.sort((o1, o2) -> Double.compare(o2.getCurrentZ(), o1.getCurrentZ())); for (RoomItem item : sortedItems) { if ((item.getCurrentPosition().getX() == roller.getCurrentPosition().getX() && item.getCurrentPosition().getY() == roller.getCurrentPosition().getY() && zOffset <= 0) && (item != roller)) { @@ -739,7 +550,7 @@ public class RoomUnitManager { if (!messages.isEmpty()) { for (MessageComposer message : messages) { - this.sendComposer(message.compose()); + sendComposer(message.compose()); } messages.clear(); } @@ -759,7 +570,7 @@ public class RoomUnitManager { } if (!updatedUnit.isEmpty()) { - this.sendComposer(new UserUpdateComposer(updatedUnit).compose()); + sendComposer(new UserUpdateComposer(updatedUnit).compose()); } room.getRoomTraxManager().cycle(); @@ -774,7 +585,32 @@ public class RoomUnitManager { return foundRightHolder; } - private void sendComposer(ServerMessage serverMessage) { - room.sendComposer(serverMessage); + public void updateRoomUnit(RoomUnit roomUnit) { + RoomItem item = room.getRoomItemManager().getTopItemAt(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY()); + + if ((item == null && !roomUnit.isCmdSitEnabled()) || (item != null && !item.getBaseItem().allowSit())) + roomUnit.removeStatus(RoomUnitStatus.SIT); + + double oldZ = roomUnit.getCurrentZ(); + + if (item != null) { + if (item.getBaseItem().allowSit()) { + roomUnit.setCurrentZ(item.getCurrentZ()); + } else { + roomUnit.setCurrentZ(item.getCurrentZ() + Item.getCurrentHeight(item)); + } + + if (oldZ != roomUnit.getCurrentZ()) { + room.scheduledTasks.add(() -> { + try { + item.onWalkOn(roomUnit, room, null); + } catch (Exception ignored) { + + } + }); + } + } + + this.sendComposer(new UserUpdateComposer(roomUnit).compose()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/bots/RoomBotManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/bots/RoomBotManager.java index 63060c8b..0a2e81c1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/bots/RoomBotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/bots/RoomBotManager.java @@ -5,10 +5,10 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnitManager; import com.eu.habbo.habbohotel.rooms.bots.entities.RoomBot; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.constants.RoomTileState; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; @@ -38,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; -import static com.eu.habbo.habbohotel.rooms.Room.CAUGHT_EXCEPTION; +import static com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration.CAUGHT_EXCEPTION; @Slf4j @@ -118,6 +118,15 @@ public class RoomBotManager extends RoomUnitSubManager { public Collection getBotsAt(RoomTile tile) { return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); } + public Collection getBotsOnItem(RoomItem item) { + return currentBots.values().stream() + .filter(bot -> + bot.getRoomUnit().getCurrentPosition().getX() >= item.getCurrentPosition().getX() && + bot.getRoomUnit().getCurrentPosition().getX() < item.getCurrentPosition().getX() + item.getBaseItem().getLength() && + bot.getRoomUnit().getCurrentPosition().getY() >= item.getCurrentPosition().getY() && + bot.getRoomUnit().getCurrentPosition().getY() < item.getCurrentPosition().getY() + item.getBaseItem().getWidth()) + .toList(); + } public void placeBot(Bot bot, Habbo botOwner, int x, int y) { synchronized (this.currentBots) { @@ -137,7 +146,7 @@ public class RoomBotManager extends RoomUnitSubManager { } } - if (this.currentBots.size() >= Room.MAXIMUM_BOTS && !botOwner.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { + if (this.currentBots.size() >= RoomConfiguration.MAXIMUM_BOTS && !botOwner.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS)) { botOwner.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/bots/entities/RoomBot.java b/src/main/java/com/eu/habbo/habbohotel/rooms/bots/entities/RoomBot.java index 24d30e82..c76cb1bc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/bots/entities/RoomBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/bots/entities/RoomBot.java @@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.rooms.bots.entities; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.constants.RoomUserAction; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/chat/RoomChatManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/chat/RoomChatManager.java new file mode 100644 index 00000000..472a0a4f --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/chat/RoomChatManager.java @@ -0,0 +1,301 @@ +package com.eu.habbo.habbohotel.rooms.chat; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionMuteArea; +import com.eu.habbo.habbohotel.items.interactions.InteractionTalkingFurniture; +import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomLayout; +import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; +import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; +import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; +import com.eu.habbo.habbohotel.rooms.types.IRoomManager; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.WiredTriggerType; +import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.outgoing.rooms.users.*; +import com.eu.habbo.messages.outgoing.users.RemainingMutePeriodComposer; +import com.eu.habbo.plugin.events.users.UserIdleEvent; +import com.eu.habbo.plugin.events.users.UsernameTalkEvent; +import com.eu.habbo.threading.runnables.YouAreAPirate; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; +import java.util.regex.Pattern; + +import static com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration.CAUGHT_EXCEPTION; + +@Getter +@Slf4j +public class RoomChatManager extends IRoomManager { + @Setter + private volatile boolean muted; + + private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30); + + public RoomChatManager(Room room) { + super(room); + } + + public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) { + this.talk(habbo, roomChatMessage, chatType, false); + } + + private void showTentChatMessageOutsideTentIfPermitted(Habbo receivingHabbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle) { + if (receivingHabbo != null && receivingHabbo.hasPermissionRight(Permission.ACC_SEE_TENTCHAT) && tentRectangle != null && !RoomLayout.tileInSquare(tentRectangle, receivingHabbo.getRoomUnit().getCurrentPosition())) { + RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); + staffChatMessage.setMessage("[" + Emulator.getTexts().getValue("hotel.room.tent.prefix") + "] " + staffChatMessage.getMessage()); + final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); + receivingHabbo.getClient().sendResponse(staffMessage); + } + } + + + public void talk(final Habbo habbo, final RoomChatMessage roomChatMessage, RoomChatType chatType, boolean ignoreWired) { + if (!habbo.getHabboStats().allowTalk()) return; + + if (habbo.getRoomUnit().isInvisible() && Emulator.getConfig().getBoolean("invisible.prevent.chat", false)) { + if (!Emulator.getGameEnvironment().getCommandsManager().handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { + habbo.whisper(Emulator.getTexts().getValue("invisible.prevent.chat.error")); + } + return; + } + + if (habbo.getRoomUnit().getRoom() != room) return; + + long millis = System.currentTimeMillis(); + if (RoomConfiguration.HABBO_CHAT_DELAY && millis - habbo.getHabboStats().getLastChat() < 750) { + return; + } + + habbo.getHabboStats().setLastChat(millis); + if (roomChatMessage != null && Emulator.getConfig().getBoolean("easter_eggs.enabled") && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { + habbo.getHabboStats().getChatCounter().addAndGet(1); + Emulator.getThreading().run(new YouAreAPirate(habbo, room)); + return; + } + + UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.TALKED, false); + Emulator.getPluginManager().fireEvent(event); + + if (!event.isCancelled() && !event.isIdle()) { + habbo.getRoomUnit().unIdle(); + } + + this.sendComposer(new UserTypingMessageComposer(habbo.getRoomUnit(), false).compose()); + + if (roomChatMessage == null || roomChatMessage.getMessage() == null || roomChatMessage.getMessage().isEmpty()) + return; + + if (!habbo.hasPermissionRight(Permission.ACC_NOMUTE) && (!RoomConfiguration.MUTEAREA_CAN_WHISPER || chatType != RoomChatType.WHISPER)) { + for (RoomItem area : room.getRoomSpecialTypes().getItemsOfType(InteractionMuteArea.class)) { + if (((InteractionMuteArea) area).inSquare(habbo.getRoomUnit().getCurrentPosition())) { + return; + } + } + } + + if (!room.getRoomWordFilterManager().getFilteredWords().isEmpty() && !habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FILTER)) { + for (String string : room.getRoomWordFilterManager().getFilteredWords()) { + roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba")); + } + } + + if (!habbo.hasPermissionRight(Permission.ACC_NOMUTE)) { + if (this.isMuted() && !room.getRoomRightsManager().hasRights(habbo)) { + return; + } + + if (room.getRoomInfractionManager().isMuted(habbo)) { + habbo.getClient().sendResponse(new RemainingMutePeriodComposer(room.getRoomInfractionManager().getMutedHabbos().get(habbo.getHabboInfo().getId()) - Emulator.getIntUnixTimestamp())); + return; + } + } + + if (chatType != RoomChatType.WHISPER) { + if (Emulator.getGameEnvironment().getCommandsManager().handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { + WiredHandler.handle(WiredTriggerType.SAY_COMMAND, habbo.getRoomUnit(), habbo.getRoomUnit().getRoom(), new Object[]{roomChatMessage.getMessage()}); + roomChatMessage.isCommand = true; + return; + } + + if (!ignoreWired) { + if (WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, habbo.getRoomUnit(), habbo.getRoomUnit().getRoom(), new Object[]{roomChatMessage.getMessage()})) { + habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(roomChatMessage.getMessage(), habbo, habbo, roomChatMessage.getBubble()))); + return; + } + } + } + + if (!habbo.hasPermissionRight(Permission.ACC_CHAT_NO_FLOOD)) { + final int chatCounter = habbo.getHabboStats().getChatCounter().addAndGet(1); + + if (chatCounter > 3) { + final boolean floodRights = Emulator.getConfig().getBoolean("flood.with.rights"); + final boolean hasRights = room.getRoomRightsManager().hasRights(habbo); + + if (floodRights || !hasRights) { + if (room.getRoomInfo().getChatProtection() == 0 || (room.getRoomInfo().getChatProtection() == 1 && chatCounter > 4) || (room.getRoomInfo().getChatProtection() == 2 && chatCounter > 5)) { + room.getRoomInfractionManager().floodMuteHabbo(habbo, muteTime); + return; + } + } + } + } + + ServerMessage prefixMessage = null; + + if (Emulator.getPluginManager().isRegistered(UsernameTalkEvent.class, true)) { + UsernameTalkEvent usernameTalkEvent = Emulator.getPluginManager().fireEvent(new UsernameTalkEvent(habbo, roomChatMessage, chatType)); + if (usernameTalkEvent.hasCustomComposer()) { + prefixMessage = usernameTalkEvent.getCustomComposer(); + } + } + + if (prefixMessage == null) { + prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getPermissionGroup().hasPrefix() ? new UserNameChangedMessageComposer(habbo, true).compose() : null; + } + ServerMessage clearPrefixMessage = prefixMessage != null ? new UserNameChangedMessageComposer(habbo).compose() : null; + + Rectangle tentRectangle = room.getRoomSpecialTypes().tentAt(habbo.getRoomUnit().getCurrentPosition()); + + String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$", ""); + + if (trimmedMessage.isEmpty()) trimmedMessage = " "; + + roomChatMessage.setMessage(trimmedMessage); + + if (chatType == RoomChatType.WHISPER) { + if (roomChatMessage.getTargetHabbo() == null) { + return; + } + + whisper(habbo, roomChatMessage, prefixMessage, clearPrefixMessage); + } else if (chatType == RoomChatType.TALK) { + talk(habbo, roomChatMessage, tentRectangle, prefixMessage, clearPrefixMessage); + } else if (chatType == RoomChatType.SHOUT) { + shout(habbo, roomChatMessage, tentRectangle, prefixMessage, clearPrefixMessage); + } + + if (chatType == RoomChatType.TALK || chatType == RoomChatType.SHOUT) { + synchronized (room.getRoomUnitManager().getRoomBotManager().getCurrentBots()) { + room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values().forEach(b -> b.onUserSay(roomChatMessage)); + } + + if (roomChatMessage.getBubble().triggersTalkingFurniture()) { + triggerTalkingFurni(habbo); + } + } + } + + private void triggerTalkingFurni(Habbo habbo) { + THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionTalkingFurniture.class); + + for (RoomItem item : items) { + if (room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()).distance(habbo.getRoomUnit().getCurrentPosition()) <= Emulator.getConfig().getInt("furniture.talking.range")) { + int count = Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.count", 0); + + if (count > 0) { + int randomValue = Emulator.getRandom().nextInt(count + 1); + + RoomChatMessage itemMessage = new RoomChatMessage(Emulator.getTexts().getValue(item.getBaseItem().getName() + ".message." + randomValue, item.getBaseItem().getName() + ".message." + randomValue + " not found!"), habbo, RoomChatMessageBubbles.getBubble(Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.bubble", RoomChatMessageBubbles.PARROT.getType()))); + + this.sendComposer(new ChatMessageComposer(itemMessage).compose()); + + try { + item.onClick(habbo.getClient(), room, new Object[0]); + item.setExtraData("1"); + room.updateItemState(item); + + Emulator.getThreading().run(() -> { + item.setExtraData("0"); + room.updateItemState(item); + }, 2000); + + break; + } catch (Exception e) { + log.error(CAUGHT_EXCEPTION, e); + } + } + } + } + } + + private void shout(Habbo habbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle, ServerMessage prefixMessage, ServerMessage clearPrefixMessage) { + ServerMessage message = new ShoutMessageComposer(roomChatMessage).compose(); + + for (Habbo h : room.getRoomUnitManager().getCurrentHabbos().values()) { + // Show the message + // If the receiving Habbo has not ignored the sending Habbo + // AND the sending Habbo is NOT in a tent OR the receiving Habbo is in the same tent as the sending Habbo + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { + if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { + h.getClient().sendResponse(prefixMessage); + } + h.getClient().sendResponse(message); + if (clearPrefixMessage != null && !h.getHabboStats().isPreferOldChat()) { + h.getClient().sendResponse(clearPrefixMessage); + } + continue; + } + // Staff should be able to see the tent chat anyhow, even when not in the same tent + showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle); + } + } + + private void talk(Habbo habbo, RoomChatMessage roomChatMessage, Rectangle tentRectangle, ServerMessage prefixMessage, ServerMessage clearPrefixMessage) { + ServerMessage message = new ChatMessageComposer(roomChatMessage).compose(); + boolean noChatLimit = habbo.hasPermissionRight(Permission.ACC_CHAT_NO_LIMIT); + + for (Habbo h : room.getRoomUnitManager().getCurrentHabbos().values()) { + if ((h.getRoomUnit().getCurrentPosition().distance(habbo.getRoomUnit().getCurrentPosition()) <= room.getRoomInfo().getChatDistance() || h.equals(habbo) || room.getRoomRightsManager().hasRights(h) || noChatLimit) && (tentRectangle == null || RoomLayout.tileInSquare(tentRectangle, h.getRoomUnit().getCurrentPosition()))) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + if (prefixMessage != null && !h.getHabboStats().isPreferOldChat()) { + h.getClient().sendResponse(prefixMessage); + } + h.getClient().sendResponse(message); + if (clearPrefixMessage != null && !h.getHabboStats().isPreferOldChat()) { + h.getClient().sendResponse(clearPrefixMessage); + } + } + continue; + } + // Staff should be able to see the tent chat anyhow + showTentChatMessageOutsideTentIfPermitted(h, roomChatMessage, tentRectangle); + } + } + + private void whisper(Habbo habbo, RoomChatMessage roomChatMessage, ServerMessage prefixMessage, ServerMessage clearPrefixMessage) { + RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); + staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage()); + + final ServerMessage message = new WhisperMessageComposer(roomChatMessage).compose(); + final ServerMessage staffMessage = new WhisperMessageComposer(staffChatMessage).compose(); + + for (Habbo h : room.getRoomUnitManager().getCurrentHabbos().values()) { + if (h == roomChatMessage.getTargetHabbo() || h == habbo) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + if (prefixMessage != null) { + h.getClient().sendResponse(prefixMessage); + } + h.getClient().sendResponse(message); + + if (clearPrefixMessage != null) { + h.getClient().sendResponse(clearPrefixMessage); + } + } + + continue; + } + if (h.hasPermissionRight(Permission.ACC_SEE_WHISPERS)) { + h.getClient().sendResponse(staffMessage); + } + } + } + +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/chat/RoomChatMessage.java similarity index 99% rename from src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/chat/RoomChatMessage.java index c06544d4..90c1c649 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/chat/RoomChatMessage.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.rooms; +package com.eu.habbo.habbohotel.rooms.chat; import com.eu.habbo.Emulator; import com.eu.habbo.core.DatabaseLoggable; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/constants/RoomConfiguration.java b/src/main/java/com/eu/habbo/habbohotel/rooms/constants/RoomConfiguration.java new file mode 100644 index 00000000..fab83245 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/constants/RoomConfiguration.java @@ -0,0 +1,24 @@ +package com.eu.habbo.habbohotel.rooms.constants; + +import com.eu.habbo.habbohotel.rooms.Room; + +import java.util.Comparator; + +public class RoomConfiguration { + public static final double MAXIMUM_FURNI_HEIGHT = 40d; + public static final String CAUGHT_EXCEPTION = "Caught exception"; + public static final Comparator SORT_SCORE = Comparator.comparingInt(room -> room.getRoomInfo().getScore()); + public static final Comparator SORT_ID = Comparator.comparingInt(room -> room.getRoomInfo().getId()); + public static final Comparator SORT_USERS_COUNT = Comparator.comparingInt((Room room) -> room.getRoomUnitManager().getRoomHabbosCount()).thenComparing(SORT_ID); + public static boolean HABBO_CHAT_DELAY = false; + public static int MAXIMUM_BOTS = 10; + public static int MAXIMUM_PETS = 10; + public static int MAXIMUM_FURNI = 2500; + public static int MAXIMUM_POSTITNOTES = 200; + public static int HAND_ITEM_TIME = 10; + public static int IDLE_CYCLES = 240; + public static int IDLE_CYCLES_KICK = 480; + public static String PREFIX_FORMAT = "[%prefix%] "; + public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1; + public static boolean MUTEAREA_CAN_WHISPER = false; +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java index 66cbe021..13c9f3ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomHabbo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; @@ -116,11 +117,11 @@ public class RoomHabbo extends RoomAvatar { } public boolean isIdle() { - return this.idleTicks > Room.IDLE_CYCLES; + return this.idleTicks > RoomConfiguration.IDLE_CYCLES; } public void setIdle() { - this.idleTicks = Room.IDLE_CYCLES + 1; + this.idleTicks = RoomConfiguration.IDLE_CYCLES + 1; } public void incrementIdleTicks() { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java b/src/main/java/com/eu/habbo/habbohotel/rooms/infractions/RoomBan.java similarity index 97% rename from src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/infractions/RoomBan.java index 8260c736..9f3e7373 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/infractions/RoomBan.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.rooms; +package com.eu.habbo.habbohotel.rooms.infractions; import com.eu.habbo.Emulator; import com.eu.habbo.database.DatabaseConstants; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/infractions/RoomInfractionManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/infractions/RoomInfractionManager.java new file mode 100644 index 00000000..73841a29 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/infractions/RoomInfractionManager.java @@ -0,0 +1,110 @@ +package com.eu.habbo.habbohotel.rooms.infractions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.database.DatabaseConstants; +import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.types.IRoomManager; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.rooms.users.UserUnbannedFromRoomComposer; +import gnu.trove.map.hash.TIntIntHashMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Getter +@Slf4j +public class RoomInfractionManager extends IRoomManager { + + private final TIntObjectHashMap bannedHabbos; + private final TIntIntHashMap mutedHabbos; + + public RoomInfractionManager(Room room) { + super(room); + this.bannedHabbos = new TIntObjectHashMap<>(); + this.mutedHabbos = new TIntIntHashMap(); + } + + public void loadBans(Connection connection) { + this.bannedHabbos.clear(); + + try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) { + statement.setInt(1, Emulator.getIntUnixTimestamp()); + statement.setInt(2, room.getRoomInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + if (this.bannedHabbos.containsKey(set.getInt(DatabaseConstants.USER_ID))) + continue; + + this.bannedHabbos.put(set.getInt(DatabaseConstants.USER_ID), new RoomBan(set)); + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + + public void unbanHabbo(int userId) { + RoomBan ban = this.bannedHabbos.remove(userId); + + if (ban != null) { + ban.delete(); + } + + this.sendComposer(new UserUnbannedFromRoomComposer(room, userId).compose()); + } + + public boolean isBanned(Habbo habbo) { + RoomBan ban = this.bannedHabbos.get(habbo.getHabboInfo().getId()); + + boolean banned = ban != null && ban.getEndTimestamp() > Emulator.getIntUnixTimestamp() && !habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermissionRight(Permission.ACC_ENTERANYROOM); + + if (!banned && ban != null) { + this.unbanHabbo(habbo.getHabboInfo().getId()); + } + + return banned; + } + + public void addRoomBan(RoomBan roomBan) { + this.bannedHabbos.put(roomBan.getUserId(), roomBan); + } + + public void muteHabbo(Habbo habbo, int minutes) { + synchronized (this.mutedHabbos) { + this.mutedHabbos.put(habbo.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + (minutes * 60)); + } + } + + public boolean isMuted(Habbo habbo) { + if (room.getRoomInfo().isRoomOwner(habbo) || room.getRoomRightsManager().hasRights(habbo)) + return false; + + if (this.mutedHabbos.containsKey(habbo.getHabboInfo().getId())) { + boolean time = this.mutedHabbos.get(habbo.getHabboInfo().getId()) > Emulator.getIntUnixTimestamp(); + + if (!time) { + this.mutedHabbos.remove(habbo.getHabboInfo().getId()); + } + + return time; + } + + return false; + } + + + public void floodMuteHabbo(Habbo habbo, int timeOut) { + habbo.getHabboStats().setMutedCount(habbo.getHabboStats().getMutedCount() + 1); + timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().getMutedCount(), 2))); + habbo.getHabboStats().getChatCounter().set(0); + habbo.mute(timeOut, true); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/items/RoomItemManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/items/RoomItemManager.java index 595dd1b8..885bf5bd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/items/RoomItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/items/RoomItemManager.java @@ -14,6 +14,7 @@ import com.eu.habbo.habbohotel.items.interactions.pets.*; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.constants.FurnitureMovementError; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.constants.RoomRightLevels; import com.eu.habbo.habbohotel.rooms.constants.RoomTileState; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; @@ -120,8 +121,8 @@ public class RoomItemManager { } 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); + if (this.currentItems.size() > RoomConfiguration.MAXIMUM_FURNI) { + log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.room.getRoomInfo().getId(), this.currentItems.size(), RoomConfiguration.MAXIMUM_FURNI); } synchronized (this.currentItems) { @@ -170,7 +171,7 @@ public class RoomItemManager { } public FurnitureMovementError canPlaceFurnitureAt(RoomItem item, Habbo habbo, RoomTile tile, int rotation) { - if (this.currentItems.size() >= Room.MAXIMUM_FURNI) { + if (this.currentItems.size() >= RoomConfiguration.MAXIMUM_FURNI) { return FurnitureMovementError.MAX_ITEMS; } else if (item instanceof InteractionMoodLight && !this.getItemsOfType(InteractionMoodLight.class).isEmpty()) { return FurnitureMovementError.MAX_DIMMERS; @@ -345,7 +346,7 @@ public class RoomItemManager { return FurnitureMovementError.TILE_HAS_HABBOS; if (!this.room.getRoomUnitManager().getRoomBotManager().getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS; - if (this.room.getRoomUnitManager().hasPetsAt(t)) + if (this.room.getRoomUnitManager().getRoomPetManager().hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS; } } @@ -380,7 +381,7 @@ public class RoomItemManager { } } - if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getCurrentZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > Room.MAXIMUM_FURNI_HEIGHT)) { + if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getCurrentZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > RoomConfiguration.MAXIMUM_FURNI_HEIGHT)) { item.setRotation(oldRotation); return FurnitureMovementError.CANT_STACK; } @@ -405,7 +406,7 @@ public class RoomItemManager { } } - if (height > Room.MAXIMUM_FURNI_HEIGHT) { + if (height > RoomConfiguration.MAXIMUM_FURNI_HEIGHT) { return FurnitureMovementError.CANT_STACK; } @@ -420,7 +421,7 @@ public class RoomItemManager { } } - if (height > Room.MAXIMUM_FURNI_HEIGHT) { + if (height > RoomConfiguration.MAXIMUM_FURNI_HEIGHT) { return FurnitureMovementError.CANT_STACK; } @@ -436,8 +437,8 @@ public class RoomItemManager { item.setExtraData(String.valueOf(item.getCurrentZ() * 100)); } - if (item.getCurrentZ() > Room.MAXIMUM_FURNI_HEIGHT) { - item.setCurrentZ(Room.MAXIMUM_FURNI_HEIGHT); + if (item.getCurrentZ() > RoomConfiguration.MAXIMUM_FURNI_HEIGHT) { + item.setCurrentZ(RoomConfiguration.MAXIMUM_FURNI_HEIGHT); } //Update Furniture @@ -608,7 +609,7 @@ public class RoomItemManager { return FurnitureMovementError.TILE_HAS_HABBOS; if (checkForUnits && this.room.getRoomUnitManager().getRoomBotManager().hasBotsAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_BOTS; - if (checkForUnits && this.room.getRoomUnitManager().hasPetsAt(occupiedTile)) + if (checkForUnits && this.room.getRoomUnitManager().getRoomPetManager().hasPetsAt(occupiedTile)) return FurnitureMovementError.TILE_HAS_PETS; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/pets/RoomPetManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/pets/RoomPetManager.java new file mode 100644 index 00000000..a347ddd3 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/pets/RoomPetManager.java @@ -0,0 +1,256 @@ +package com.eu.habbo.habbohotel.rooms.pets; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.pets.Pet; +import com.eu.habbo.habbohotel.pets.PetManager; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.RoomUnitManager; +import com.eu.habbo.habbohotel.rooms.constants.RoomTileState; +import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; +import com.eu.habbo.habbohotel.rooms.entities.RoomRotation; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; +import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; +import com.eu.habbo.habbohotel.rooms.pets.entities.RoomPet; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomUnitSubManager; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.inventory.PetAddedToInventoryComposer; +import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; +import gnu.trove.set.hash.THashSet; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Slf4j +public class RoomPetManager extends RoomUnitSubManager { + @Getter + private final ConcurrentHashMap currentPets; + + public RoomPetManager(RoomUnitManager roomUnitManager) { + super(roomUnitManager); + this.currentPets = new ConcurrentHashMap<>(); + } + + public synchronized void loadPets(Connection connection) { + this.currentPets.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.room.getRoomInfo().getId()); + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + Pet pet = PetManager.loadPet(set); + + pet.setRoom(this.room); + 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(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")]); + } + pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); + pet.getRoomUnit().setCanWalk(true); + roomUnitManager.addRoomUnit(pet); + this.room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } catch (Exception e) { + log.error("Caught Exception", e); + } + } + + public void placePet(Pet pet, Room room, short x, short y, double z) { + synchronized (this.currentPets) { + RoomTile spawnTile = room.getLayout().getTile(x, y); + + if (spawnTile == null) { + spawnTile = room.getLayout().getDoorTile(); + } + + pet.setRoom(room); + pet.getRoomUnit().walkTo(spawnTile); + pet.getRoomUnit().setLocation(spawnTile) + .setRoomUnitType(RoomUnitType.PET) + .setCanWalk(true) + .setCurrentZ(z); + + if (pet.getRoomUnit().getCurrentPosition() == null) { + pet.getRoomUnit() + .setLocation(room.getLayout().getDoorTile()) + .setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection())); + } + + pet.setSqlUpdateNeeded(true); + room.getFurniOwnerNames().put(pet.getUserId(), roomUnitManager.getRoomHabboById(pet.getUserId()).getHabboInfo().getUsername()); + roomUnitManager.addRoomUnit(pet); + room.sendComposer(new RoomPetComposer(pet).compose()); + } + } + + public boolean hasPetsAt(RoomTile tile) { + return this.currentPets.values().stream().anyMatch(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)); + } + + public Collection getPetsAt(RoomTile tile) { + return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet()); + } + + public Collection getPetsOnItem(RoomItem item) { + return currentPets.values().stream() + .filter(pet -> + pet.getRoomUnit().getCurrentPosition().getX() >= item.getCurrentPosition().getX() && + pet.getRoomUnit().getCurrentPosition().getX() < item.getCurrentPosition().getX() + item.getBaseItem().getLength() && + pet.getRoomUnit().getCurrentPosition().getY() >= item.getCurrentPosition().getY() && + pet.getRoomUnit().getCurrentPosition().getY() < item.getCurrentPosition().getY() + item.getBaseItem().getWidth()) + .toList(); + } + + public Pet getRoomPetById(int petId) { + return this.currentPets.get(petId); + } + + public Pet getPetByRoomUnit(RoomUnit roomUnit) { + return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit() == roomUnit).findFirst().orElse(null); + } + + public void pickUpMyPets(Habbo owner) { + THashSet pets = new THashSet<>(); + + synchronized (this.currentPets) { + for (Pet pet : this.currentPets.values()) { + if (pet.getUserId() == owner.getHabboInfo().getId()) { + pets.add(pet); + } + } + } + + for (Pet pet : pets) { + pet.removeFromRoom(); + Emulator.getThreading().run(pet); + owner.getInventory().getPetsComponent().addPet(pet); + owner.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); + this.currentPets.remove(pet.getId()); + } + } + + public Pet removePet(int petId) { + Pet pet = currentPets.get(petId); + roomUnitManager.removeUnit(pet.getRoomUnit().getVirtualId()); + return remove(petId); + } + + public void removeAllPetsExceptRoomOwner() { + ArrayList toRemovePets = new ArrayList<>(); + ArrayList removedPets = new ArrayList<>(); + synchronized (currentPets) { + for (Pet pet : currentPets.values()) { + try { + if (pet.getUserId() != pet.getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId()) { + toRemovePets.add(pet); + } + + } catch (NoSuchElementException e) { + log.error("Caught exception", e); + break; + } + } + } + + for (Pet pet : toRemovePets) { + removedPets.add(pet); + + pet.removeFromRoom(); + + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()); + if (habbo != null) { + habbo.getInventory().getPetsComponent().addPet(pet); + habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet)); + } + + pet.setSqlUpdateNeeded(true); + pet.run(); + } + + for (Pet pet : removedPets) { + currentPets.remove(pet.getId()); + roomUnitManager.removeUnit(pet.getRoomUnit().getVirtualId()); + } + } + + @Override + public List cycle() { + List updatedUnits = new ArrayList<>(); + if (!getCurrentPets().isEmpty() && room.isAllowBotsWalk()) { + Iterator petIterator = getCurrentPets().values().iterator(); + while (petIterator.hasNext()) { + final Pet pet; + try { + pet = petIterator.next(); + } catch (Exception e) { + break; + } + + pet.getRoomUnit().cycle(); + pet.cycle(); + + if (pet.getRoomUnit().isStatusUpdateNeeded()) { + pet.getRoomUnit().setStatusUpdateNeeded(false); + updatedUnits.add(pet.getRoomUnit()); + } + + if (pet.getRoomUnit().isWalking() && pet.getRoomUnit().getPath().size() == 1 && pet.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) { + pet.getRoomUnit().removeStatus(RoomUnitStatus.GESTURE); + updatedUnits.add(pet.getRoomUnit()); + } + } + } + + return updatedUnits; + } + + public void addPet(Pet pet) { + currentPets.put(pet.getId(), pet); + } + + public Pet remove(int petId) { + return currentPets.remove(petId); + } + + public void clear() { + currentPets.clear(); + } + + public void dispose() { + Iterator petIterator = this.currentPets.values().iterator(); + + while (petIterator.hasNext()) { + try { + Pet pet = petIterator.next(); + pet.setSqlUpdateNeeded(true); + Emulator.getThreading().run(pet); + } catch (NoSuchElementException e) { + log.error("Caught Exception", e); + break; + } + } + + this.currentPets.clear(); + } + + +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java b/src/main/java/com/eu/habbo/habbohotel/rooms/pets/entities/RoomPet.java similarity index 94% rename from src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/pets/entities/RoomPet.java index 8fdd46b6..340aed50 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/entities/units/types/RoomPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/pets/entities/RoomPet.java @@ -1,10 +1,11 @@ -package com.eu.habbo.habbohotel.rooms.entities.units.types; +package com.eu.habbo.habbohotel.rooms.pets.entities; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; +import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar; import com.eu.habbo.habbohotel.users.Habbo; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/promotions/RoomPromotion.java similarity index 95% rename from src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/promotions/RoomPromotion.java index 02933c3e..fed9987d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/promotions/RoomPromotion.java @@ -1,6 +1,7 @@ -package com.eu.habbo.habbohotel.rooms; +package com.eu.habbo.habbohotel.rooms.promotions; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.Room; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/promotions/RoomPromotionManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/promotions/RoomPromotionManager.java new file mode 100644 index 00000000..54871dfb --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/promotions/RoomPromotionManager.java @@ -0,0 +1,86 @@ +package com.eu.habbo.habbohotel.rooms.promotions; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.types.IRoomManager; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION; + +@Slf4j +@Getter +public class RoomPromotionManager extends IRoomManager { + + private RoomPromotion promotion; + + public RoomPromotionManager(Room room) { + super(room); + } + + public void loadPromotions(Connection connection) { + if (room.getRoomInfo().isPromoted()) { + try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) { + statement.setInt(1, room.getRoomInfo().getId()); + statement.setInt(2, Emulator.getIntUnixTimestamp()); + + try (ResultSet promotionSet = statement.executeQuery()) { + room.getRoomInfo().setPromoted(false); + if (promotionSet.next()) { + room.getRoomInfo().setPromoted(true); + this.promotion = new RoomPromotion(room, promotionSet); + } + } + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + } + } + + public boolean isPromoted() { + room.getRoomInfo().setPromoted(this.promotion != null && this.promotion.getEndTimestamp() > Emulator.getIntUnixTimestamp()); + room.setNeedsUpdate(true); + return room.getRoomInfo().isPromoted(); + } + + public String getPromotionDesc() { + return this.promotion != null ? this.promotion.getDescription() : ""; + + } + + public void createPromotion(String title, String description, int category) { + room.getRoomInfo().setPromoted(true); + + if (this.promotion == null) { + this.promotion = new RoomPromotion(room, title, description, Emulator.getIntUnixTimestamp() + (120 * 60), Emulator.getIntUnixTimestamp(), category); + } else { + this.promotion.setTitle(title); + this.promotion.setDescription(description); + this.promotion.setEndTimestamp(Emulator.getIntUnixTimestamp() + (120 * 60)); + this.promotion.setCategory(category); + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_promotions (room_id, title, description, end_timestamp, start_timestamp, category) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE title = ?, description = ?, end_timestamp = ?, category = ?")) { + statement.setInt(1, room.getRoomInfo().getId()); + statement.setString(2, title); + statement.setString(3, description); + statement.setInt(4, this.promotion.getEndTimestamp()); + statement.setInt(5, this.promotion.getStartTimestamp()); + statement.setInt(6, category); + statement.setString(7, this.promotion.getTitle()); + statement.setString(8, this.promotion.getDescription()); + statement.setInt(9, this.promotion.getEndTimestamp()); + statement.setInt(10, this.promotion.getCategory()); + statement.execute(); + } catch (SQLException e) { + log.error(CAUGHT_SQL_EXCEPTION, e); + } + + room.setNeedsUpdate(true); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTrade.java similarity index 97% rename from src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTrade.java index db0c3b57..d1d69be4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTrade.java @@ -1,6 +1,7 @@ -package com.eu.habbo.habbohotel.rooms; +package com.eu.habbo.habbohotel.rooms.trades; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; @@ -134,7 +135,7 @@ public class RoomTrade { this.sendMessageToUsers(new TradingNotOpenComposer()); } - this.room.stopTrade(this); + this.room.getRoomTradeManager().stopTrade(this); } } @@ -285,12 +286,12 @@ public class RoomTrade { } private void closeWindow() { - this.removeStatusses(); + this.removeStatuses(); this.sendMessageToUsers(new TradeCloseWindowComposer()); } public void stopTrade(Habbo habbo) { - this.removeStatusses(); + this.removeStatuses(); this.clearAccepted(); this.returnItems(); for (RoomTradeUser user : this.users) { @@ -298,10 +299,10 @@ public class RoomTrade { } this.updateWindow(); this.sendMessageToUsers(new TradingCloseComposer(habbo.getHabboInfo().getId(), TradingCloseComposer.USER_CANCEL_TRADE)); - this.room.stopTrade(this); + this.room.getRoomTradeManager().stopTrade(this); } - private void removeStatusses() { + private void removeStatuses() { for (RoomTradeUser user : this.users) { Habbo habbo = user.getHabbo(); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTradeManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTradeManager.java new file mode 100644 index 00000000..dcb69e8a --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTradeManager.java @@ -0,0 +1,41 @@ +package com.eu.habbo.habbohotel.rooms.trades; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.types.IRoomManager; +import com.eu.habbo.habbohotel.users.Habbo; +import gnu.trove.set.hash.THashSet; + +public class RoomTradeManager extends IRoomManager { + private final THashSet activeTrades; + public RoomTradeManager(Room room) { + super(room); + this.activeTrades = new THashSet<>(0); + } + + public void startTrade(Habbo userOne, Habbo userTwo) { + RoomTrade trade = new RoomTrade(userOne, userTwo, room); + synchronized (this.activeTrades) { + this.activeTrades.add(trade); + } + + trade.start(); + } + + public void stopTrade(RoomTrade trade) { + synchronized (this.activeTrades) { + this.activeTrades.remove(trade); + } + } + + public RoomTrade getActiveTradeForHabbo(Habbo user) { + synchronized (this.activeTrades) { + for (RoomTrade trade : this.activeTrades) { + for (RoomTradeUser habbo : trade.getRoomTradeUsers()) { + if (habbo.getHabbo() == user) return trade; + } + } + } + return null; + } + +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java b/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTradeUser.java similarity index 96% rename from src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java rename to src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTradeUser.java index af9009f7..e10e21df 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTradeUser.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/trades/RoomTradeUser.java @@ -1,4 +1,4 @@ -package com.eu.habbo.habbohotel.rooms; +package com.eu.habbo.habbohotel.rooms.trades; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/types/IRoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/types/IRoomManager.java new file mode 100644 index 00000000..be619a44 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/types/IRoomManager.java @@ -0,0 +1,16 @@ +package com.eu.habbo.habbohotel.rooms.types; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.messages.ServerMessage; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public abstract class IRoomManager { + @Getter + protected final Room room; + + protected void sendComposer(ServerMessage message){ + room.sendComposer(message); + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/utils/cycle/CycleFunctions.java b/src/main/java/com/eu/habbo/habbohotel/rooms/utils/cycle/CycleFunctions.java index 16276b4d..6eb29a79 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/utils/cycle/CycleFunctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/utils/cycle/CycleFunctions.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms.utils.cycle; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -27,7 +28,7 @@ public class CycleFunctions { } else { habbo.getRoomUnit().incrementIdleTicks(); - if (!room.getRoomInfo().isRoomOwner(habbo) && habbo.getRoomUnit().getIdleTicks() >= Room.IDLE_CYCLES_KICK) { + if (!room.getRoomInfo().isRoomOwner(habbo) && habbo.getRoomUnit().getIdleTicks() >= RoomConfiguration.IDLE_CYCLES_KICK) { UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE); Emulator.getPluginManager().fireEvent(event); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/wordquiz/RoomWordQuizManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/wordquiz/RoomWordQuizManager.java new file mode 100644 index 00000000..79b0fffb --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/wordquiz/RoomWordQuizManager.java @@ -0,0 +1,77 @@ +package com.eu.habbo.habbohotel.rooms.wordquiz; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.types.IRoomManager; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer; +import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer; +import com.eu.habbo.messages.outgoing.polls.infobus.QuestionFinishedComposer; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; + +@Getter +public class RoomWordQuizManager extends IRoomManager { + private final List userVotes; + + private String wordQuiz = ""; + private int noVotes = 0; + private int yesVotes = 0; + private int wordQuizEnd = 0; + + public RoomWordQuizManager(Room room) { + super(room); + this.userVotes = new ArrayList<>(); + this.wordQuiz = ""; + this.yesVotes = 0; + this.noVotes = 0; + } + + public void handleWordQuiz(Habbo habbo, String answer) { + synchronized (this.userVotes) { + if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) { + answer = answer.replace(":", ""); + + if (answer.equals("0")) { + this.noVotes++; + } else if (answer.equals("1")) { + this.yesVotes++; + } + + this.sendComposer(new QuestionAnsweredComposer(habbo.getHabboInfo().getId(), answer, this.noVotes, this.yesVotes).compose()); + this.userVotes.add(habbo.getHabboInfo().getId()); + } + } + } + + public void startWordQuiz(String question, int duration) { + if (!this.hasActiveWordQuiz()) { + this.wordQuiz = question; + this.noVotes = 0; + this.yesVotes = 0; + this.userVotes.clear(); + this.wordQuizEnd = Emulator.getIntUnixTimestamp() + (duration / 1000); + this.sendComposer(new QuestionComposer(duration, question).compose()); + } + } + + public boolean hasActiveWordQuiz() { + return Emulator.getIntUnixTimestamp() < this.wordQuizEnd; + } + + public boolean hasVotedInWordQuiz(Habbo habbo) { + return this.userVotes.contains(habbo.getHabboInfo().getId()); + } + + public void onHabboEntered(Habbo habbo) { + if (room.getRoomWordQuizManager().hasActiveWordQuiz()) { + habbo.getClient().sendResponse(new QuestionComposer((Emulator.getIntUnixTimestamp() - room.getRoomWordQuizManager().getWordQuizEnd()) * 1000, room.getRoomWordQuizManager().getWordQuiz())); + + if (room.getRoomWordQuizManager().hasVotedInWordQuiz(habbo)) { + habbo.getClient().sendResponse(new QuestionFinishedComposer(room.getRoomWordQuizManager().getNoVotes(), room.getRoomWordQuizManager().getYesVotes())); + } + } + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index ff63c4d8..0121c2eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -10,7 +10,7 @@ import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.constants.RoomUserAction; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 47bc4393..158f393d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -8,7 +8,7 @@ import com.eu.habbo.habbohotel.campaign.CalendarRewardClaimed; import com.eu.habbo.habbohotel.catalog.CatalogItem; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; import com.eu.habbo.habbohotel.users.subscriptions.Subscription; import com.eu.habbo.plugin.events.users.subscriptions.UserSubscriptionCreatedEvent; diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java index 38611dac..3cc7d544 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/recycler/PresentOpenEvent.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java index 8b883f29..297764b2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/VisitUserEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.friends; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java index 42b2c00f..fee8bc8e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/DeleteRoomEvent.java @@ -55,7 +55,7 @@ public class DeleteRoomEvent extends MessageHandler { Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room); } - List pets = new ArrayList<>(room.getRoomUnitManager().getCurrentPets().values()); + List pets = new ArrayList<>(room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values()); for (Pet pet : pets) { if (pet instanceof RideablePet rideablePet) { if (rideablePet.getRider() != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index b2e2770c..97421bc4 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -29,7 +29,7 @@ public class AnswerPollEvent extends MessageHandler { if(answer.length() <= 0) return; if (pollId == 0 && questionId <= 0) { - this.client.getHabbo().getRoomUnit().getRoom().handleWordQuiz(this.client.getHabbo(), answer.toString()); + this.client.getHabbo().getRoomUnit().getRoom().getRoomWordQuizManager().handleWordQuiz(this.client.getHabbo(), answer.toString()); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java index 35576d89..30387b6f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/MuteAllInRoomEvent.java @@ -11,7 +11,7 @@ public class MuteAllInRoomEvent extends MessageHandler { if (room != null) { if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { - room.setMuted(!room.isMuted()); + room.getRoomChatManager().setMuted(!room.getRoomChatManager().isMuted()); this.client.sendResponse(new MuteAllInRoomComposer(room)); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java index be6f7b99..b44c6c13 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/SaveRoomSettingsEvent.java @@ -119,7 +119,7 @@ public class SaveRoomSettingsEvent extends MessageHandler { room.getRoomInfo().setAllowPets(this.packet.readBoolean()); if(!room.getRoomInfo().isAllowPets()) { - room.getRoomUnitManager().removeAllPetsExceptRoomOwner(); + room.getRoomUnitManager().getRoomPetManager().removeAllPetsExceptRoomOwner(); } boolean allowPetsEat = this.packet.readBoolean(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java index a09e9e95..69e93299 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PlacePostItEvent.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.items.interactions.InteractionStickyPole; import com.eu.habbo.habbohotel.rooms.constants.FurnitureMovementError; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; @@ -26,7 +27,7 @@ public class PlacePostItEvent extends MessageHandler { RoomItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId); if (item instanceof InteractionPostIt) { - if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) { + if (room.getPostItNotes().size() < RoomConfiguration.MAXIMUM_POSTITNOTES) { room.getRoomItemManager().addRoomItem(item); item.setExtraData("FFFF33"); //Deprecated diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java index db036192..978c30d1 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SetCustomStackingHeightEvent.java @@ -3,6 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.habbohotel.items.interactions.InteractionStackHelper; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer; @@ -34,7 +35,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler { } } } else { - stackerHeight = Math.min(Math.max(stackerHeight, itemTile.getZ() * 100.0), Room.MAXIMUM_FURNI_HEIGHT * 100); + stackerHeight = Math.min(Math.max(stackerHeight, itemTile.getZ() * 100.0), RoomConfiguration.MAXIMUM_FURNI_HEIGHT * 100); } double height = 0; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java index 29e72948..237ecba3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseFurnitureEvent.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionSpinningBottle; import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; @@ -50,7 +51,7 @@ public class UseFurnitureEvent extends MessageHandler { if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase())) { - if (room.getRoomUnitManager().getCurrentPets().size() < Room.MAXIMUM_PETS) { + if (room.getRoomUnitManager().getRoomPetManager().getCurrentPets().size() < RoomConfiguration.MAXIMUM_PETS) { this.client.sendResponse(new OpenPetPackageRequestedMessageComposer(item)); return; } @@ -73,7 +74,7 @@ public class UseFurnitureEvent extends MessageHandler { room.sendComposer(new RemoveFloorItemComposer(item, true).compose()); room.getRoomItemManager().removeRoomItem(item); room.updateTile(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); - room.getRoomUnitManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); + room.getRoomUnitManager().getRoomPetManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); pet.cycle(); room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose()); return true; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java index 2d022131..f17c7bfa 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/BreedPetsEvent.java @@ -11,9 +11,9 @@ public class BreedPetsEvent extends MessageHandler { if (unknownInt == 0) { int petId1 = this.packet.readInt(); - Pet petOne = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId1); + Pet petOne = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId1); int petId = this.packet.readInt(); - Pet petTwo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); + Pet petTwo = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (petOne == null || petTwo == null || petOne == petTwo) { //TODO Add error diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java index 744f6355..42e0d454 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostPlantEvent.java @@ -23,7 +23,7 @@ public class CompostPlantEvent extends MessageHandler { int petId = this.packet.readInt(); Room room = this.client.getHabbo().getRoomUnit().getRoom(); - Pet pet = room.getRoomUnitManager().getRoomPetById(petId); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet != null) { if (pet instanceof MonsterplantPet) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java index 80c66856..d5be98fe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CustomizePetWithFurniEvent.java @@ -30,7 +30,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler { return; int petId = this.packet.readInt(); - Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet instanceof HorsePet) { if (item.getBaseItem().getName().toLowerCase().startsWith("horse_dye")) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java index dcc9ea99..fb5b0705 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetCommandsEvent.java @@ -12,7 +12,7 @@ public class GetPetCommandsEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet != null) this.client.sendResponse(new PetTrainingPanelComposer(pet)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java index bf5b49a9..e18b944c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/GetPetInfoEvent.java @@ -15,7 +15,7 @@ public class GetPetInfoEvent extends MessageHandler { if (room == null) return; - Pet pet = room.getRoomUnitManager().getRoomPetById(petId); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet != null) { this.client.sendResponse(new PetInfoMessageComposer(pet, room, this.client.getHabbo())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java index fa1996e0..013da2b5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MountPetEvent.java @@ -22,7 +22,7 @@ public class MountPetEvent extends MessageHandler { return; } - Pet pet = room.getRoomUnitManager().getRoomPetById(petId); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (!(pet instanceof RideablePet rideablePet)) { return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java index 9f8b0342..97b2a8c9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/MovePetEvent.java @@ -11,7 +11,7 @@ public class MovePetEvent extends MessageHandler { @Override public void handle() { int petId = this.packet.readInt(); - Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet != null) { Room room = this.client.getHabbo().getRoomUnit().getRoom(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java index 5a16d0a1..26e6f608 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/OpenPetPackageEvent.java @@ -55,7 +55,7 @@ public class OpenPetPackageEvent extends MessageHandler { } if (pet != null) { - room.getRoomUnitManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); + room.getRoomUnitManager().getRoomPetManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ()); pet.setUserId(this.client.getHabbo().getHabboInfo().getId()); pet.setSqlUpdateNeeded(true); pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java index 3fcad775..50f4b4df 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/PlacePetEvent.java @@ -5,9 +5,10 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType; -import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet; +import com.eu.habbo.habbohotel.rooms.pets.entities.RoomPet; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.PetPlacingErrorComposer; import com.eu.habbo.messages.outgoing.inventory.PetRemovedFromInventoryComposer; @@ -36,7 +37,7 @@ public class PlacePetEvent extends MessageHandler { if (pet == null) { return; } - if (room.getRoomUnitManager().getCurrentPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS)) { + if (room.getRoomUnitManager().getRoomPetManager().getCurrentPets().size() >= RoomConfiguration.MAXIMUM_PETS && !this.client.getHabbo().hasPermissionRight(Permission.ACC_UNLIMITED_PETS)) { this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_MAX_PETS)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java index c0452168..65f08884 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemovePetFromFlatEvent.java @@ -20,7 +20,7 @@ public class RemovePetFromFlatEvent extends MessageHandler { if (room == null) return; - Pet pet = room.getRoomUnitManager().getRoomPetById(petId); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet != null) { if (this.client.getHabbo().getHabboInfo().getId() == pet.getUserId() || room.getRoomInfo().getOwnerInfo().getId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java index 89f28ad4..de53a3f8 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RemoveSaddleFromPetEvent.java @@ -25,7 +25,7 @@ public class RemoveSaddleFromPetEvent extends MessageHandler { public void handle() { Room room = this.client.getHabbo().getRoomUnit().getRoom(); int petId = this.packet.readInt(); - Pet pet = room.getRoomUnitManager().getRoomPetById(petId); + Pet pet = room.getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (!(pet instanceof HorsePet horse) || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId()) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java index 76ef0283..8abe866c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/RespectPetEvent.java @@ -24,7 +24,7 @@ public class RespectPetEvent extends MessageHandler { final Room room = habbo.getRoomUnit().getRoom(); if (room == null) { return; } - final Pet pet = room.getRoomUnitManager().getRoomPetById(petId); + final Pet pet = room.getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet == null) { return; } if (habbo.getHabboStats().getPetRespectPointsToGive() > 0 || pet instanceof MonsterplantPet) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java index be729dab..4726eab2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetBreedingPermissionEvent.java @@ -9,7 +9,7 @@ public class TogglePetBreedingPermissionEvent extends MessageHandler { public void handle() { int petId = this.packet.readInt(); - Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet != null) { if (pet.getUserId() == this.client.getHabbo().getHabboInfo().getId()) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java index 7de47b2e..172a2d10 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/TogglePetRidingPermissionEvent.java @@ -14,7 +14,7 @@ public class TogglePetRidingPermissionEvent extends MessageHandler { if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetById(petId); + Pet pet = this.client.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomPetManager().getRoomPetById(petId); if (pet == null || pet.getUserId() != this.client.getHabbo().getHabboInfo().getId() || !(pet instanceof RideablePet rideablePet)) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java index 177e3b06..49e72bb3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/EditEventEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.promotions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomPromotion; +import com.eu.habbo.habbohotel.rooms.promotions.RoomPromotion; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomEventComposer; @@ -23,7 +23,7 @@ public class EditEventEvent extends MessageHandler { return; } - RoomPromotion roomPromotion = room.getPromotion(); + RoomPromotion roomPromotion = room.getRoomPromotionManager().getPromotion(); if (roomPromotion != null) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java index b8f01327..64582f13 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/promotions/PurchaseRoomAdEvent.java @@ -42,13 +42,13 @@ public class PurchaseRoomAdEvent extends MessageHandler { return; } - if (room.isPromoted()) { - room.getPromotion().addEndTimestamp(120 * 60); + if (room.getRoomPromotionManager().isPromoted()) { + room.getRoomPromotionManager().getPromotion().addEndTimestamp(120 * 60); } else { - room.createPromotion(title, description, categoryId); + room.getRoomPromotionManager().createPromotion(title, description, categoryId); } - if (room.isPromoted()) { + if (room.getRoomPromotionManager().isPromoted()) { if (!this.client.getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS)) { this.client.getHabbo().giveCredits(-item.getCredits()); } @@ -58,7 +58,7 @@ public class PurchaseRoomAdEvent extends MessageHandler { } this.client.sendResponse(new PurchaseOKMessageComposer()); - room.sendComposer(new RoomEventComposer(room, room.getPromotion()).compose()); + room.sendComposer(new RoomEventComposer(room, room.getRoomPromotionManager().getPromotion()).compose()); if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(PurchaseRoomAdEvent.ROOM_PROMOTION_BADGE)) { this.client.getHabbo().addBadge(PurchaseRoomAdEvent.ROOM_PROMOTION_BADGE); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java index b3d9a725..ea54f2d9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ChatEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; @@ -30,7 +30,7 @@ public class ChatEvent extends MessageHandler { return; } - room.talk(this.client.getHabbo(), message, RoomChatType.TALK); + room.getRoomChatManager().talk(this.client.getHabbo(), message, RoomChatType.TALK); if (!message.isCommand) { if (RoomChatMessage.SAVE_ROOM_CHATS) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java index 26afaad9..c45d7adf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserKickEvent.java @@ -4,7 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java index b238cdad..bb2a866d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserMuteEvent.java @@ -22,7 +22,7 @@ public class RoomUserMuteEvent extends MessageHandler { Habbo habbo = room.getRoomUnitManager().getRoomHabboById(userId); if (habbo != null) { - room.muteHabbo(habbo, minutes); + room.getRoomInfractionManager().muteHabbo(habbo, minutes); habbo.getClient().sendResponse(new RemainingMutePeriodComposer(minutes * 60)); AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModMuteSeen")); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java index 83f01143..426699d0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/ShoutEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ScripterManager; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; @@ -27,7 +27,7 @@ public class ShoutEvent extends MessageHandler { return; } - this.client.getHabbo().getRoomUnit().getRoom().talk(this.client.getHabbo(), message, RoomChatType.SHOUT); + this.client.getHabbo().getRoomUnit().getRoom().getRoomChatManager().talk(this.client.getHabbo(), message, RoomChatType.SHOUT); if (!message.isCommand) { if (RoomChatMessage.SAVE_ROOM_CHATS) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java index 0741b6d0..7e1142b9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/UnbanUserFromRoomEvent.java @@ -14,7 +14,7 @@ public class UnbanUserFromRoomEvent extends MessageHandler { if (room != null) { if (room.getRoomInfo().isRoomOwner(this.client.getHabbo())) { - room.unbanHabbo(userId); + room.getRoomInfractionManager().unbanHabbo(userId); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java index f2cdb16c..45036644 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/WhisperEvent.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.users; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ScripterManager; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; @@ -26,7 +26,7 @@ public class WhisperEvent extends MessageHandler { return; } - this.client.getHabbo().getRoomUnit().getRoom().talk(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER, true); + this.client.getHabbo().getRoomUnit().getRoom().getRoomChatManager().talk(this.client.getHabbo(), chatMessage, RoomChatType.WHISPER, true); if (RoomChatMessage.SAVE_ROOM_CHATS) { Emulator.getThreading().run(chatMessage); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java index 708facba..78b52064 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/AcceptTradingEvent.java @@ -1,10 +1,9 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.incoming.MessageHandler; -public class AcceptTradingEvent extends MessageHandler { +public class AcceptTradingEvent extends TradingEvent { @Override public void handle() { Habbo habbo = this.client.getHabbo(); @@ -12,7 +11,7 @@ public class AcceptTradingEvent extends MessageHandler { if (habbo == null || habbo.getHabboInfo() == null || habbo.getRoomUnit().getRoom() == null) return; - RoomTrade trade = habbo.getRoomUnit().getRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = getActiveRoomTrade(habbo); if (trade == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java index 8cf6cad3..aeb56c92 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemToTradeEvent.java @@ -1,16 +1,15 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; -import com.eu.habbo.messages.incoming.MessageHandler; -public class AddItemToTradeEvent extends MessageHandler { +public class AddItemToTradeEvent extends TradingEvent { @Override public void handle() { if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - RoomTrade trade = this.client.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(this.client.getHabbo()); + RoomTrade trade = getActiveRoomTrade(this.client.getHabbo()); if (trade == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java index bf3e6568..b7180396 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/AddItemsToTradeEvent.java @@ -1,17 +1,16 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; -import com.eu.habbo.messages.incoming.MessageHandler; import gnu.trove.set.hash.THashSet; -public class AddItemsToTradeEvent extends MessageHandler { +public class AddItemsToTradeEvent extends TradingEvent { @Override public void handle() { if (this.client.getHabbo().getRoomUnit().getRoom() == null) return; - RoomTrade trade = this.client.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(this.client.getHabbo()); + RoomTrade trade = getActiveRoomTrade(this.client.getHabbo()); if (trade == null) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java index 3005e9b3..ab579074 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java @@ -1,10 +1,5 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.incoming.MessageHandler; - public class CloseTradingEvent extends TradingEvent { @Override public void handle() { diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java index 1a17b345..91fa5d37 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmAcceptTradingEvent.java @@ -1,14 +1,13 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.incoming.MessageHandler; -public class ConfirmAcceptTradingEvent extends MessageHandler { +public class ConfirmAcceptTradingEvent extends TradingEvent { @Override public void handle() { Habbo habbo = this.client.getHabbo(); - RoomTrade trade = habbo.getRoomUnit().getRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = getActiveRoomTrade(habbo); if (trade == null || !trade.getRoomTradeUserForHabbo(habbo).isAccepted()) return; diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java index 5b88197f..b5136fc2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java @@ -1,10 +1,5 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.incoming.MessageHandler; - public class ConfirmDeclineTradingEvent extends TradingEvent { @Override public void handle() { diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java index 6ce7b142..08492777 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/OpenTradingEvent.java @@ -3,7 +3,7 @@ package com.eu.habbo.messages.incoming.trading; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.rooms.constants.RoomUnitStatus; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; @@ -57,7 +57,7 @@ public class OpenTradingEvent extends MessageHandler { return; } - room.startTrade(this.client.getHabbo(), targetUser); + room.getRoomTradeManager().startTrade(this.client.getHabbo(), targetUser); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java index d3b83c91..b0b41d12 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/RemoveItemFromTradeEvent.java @@ -1,15 +1,14 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; -import com.eu.habbo.messages.incoming.MessageHandler; -public class RemoveItemFromTradeEvent extends MessageHandler { +public class RemoveItemFromTradeEvent extends TradingEvent { @Override public void handle() { int itemId = this.packet.readInt(); - RoomTrade trade = this.client.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(this.client.getHabbo()); + RoomTrade trade = getActiveRoomTrade(this.client.getHabbo()); if (trade != null) { RoomItem item = trade.getRoomTradeUserForHabbo(this.client.getHabbo()).getItem(itemId); diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java index 188da4d9..d4385d6a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java @@ -1,23 +1,27 @@ package com.eu.habbo.messages.incoming.trading; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; public abstract class TradingEvent extends MessageHandler { + protected RoomTrade getActiveRoomTrade(Habbo habbo){ + return habbo.getRoomUnit().getRoom().getRoomTradeManager().getActiveTradeForHabbo(habbo); + } + protected void stopTrade(Habbo habbo) { Room room = habbo.getRoomUnit().getRoom(); if (room == null) return; - RoomTrade trade = room.getActiveTradeForHabbo(habbo); + RoomTrade trade = room.getRoomTradeManager().getActiveTradeForHabbo(habbo); if (trade == null) return; trade.stopTrade(habbo); - room.stopTrade(trade); + room.getRoomTradeManager().stopTrade(trade); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java index d5d3db0c..b9f54ece 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/trading/UnacceptTradingEvent.java @@ -1,14 +1,14 @@ package com.eu.habbo.messages.incoming.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.incoming.MessageHandler; -public class UnacceptTradingEvent extends MessageHandler { +public class UnacceptTradingEvent extends TradingEvent { + @Override public void handle() { Habbo habbo = this.client.getHabbo(); - RoomTrade trade = habbo.getRoomUnit().getRoom().getActiveTradeForHabbo(habbo); + RoomTrade trade = getActiveRoomTrade(habbo); if (trade == null) return; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java index 7e7eaded..b4f365d8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BannedUsersFromRoomComposer.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.outgoing.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomBan; +import com.eu.habbo.habbohotel.rooms.infractions.RoomBan; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; @@ -22,9 +22,9 @@ public class BannedUsersFromRoomComposer extends MessageComposer { THashSet roomBans = new THashSet<>(); - TIntObjectIterator iterator = this.room.getBannedHabbos().iterator(); + TIntObjectIterator iterator = this.room.getRoomInfractionManager().getBannedHabbos().iterator(); - for (int i = this.room.getBannedHabbos().size(); i-- > 0; ) { + for (int i = this.room.getRoomInfractionManager().getBannedHabbos().size(); i-- > 0; ) { try { iterator.advance(); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java index 1948ced2..af42b19b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/GetGuestRoomResultComposer.java @@ -31,7 +31,7 @@ public class GetGuestRoomResultComposer extends MessageComposer { this.response.appendBoolean(false); } - this.response.appendBoolean(this.room.isMuted()); // isroommuted + this.response.appendBoolean(this.room.getRoomChatManager().isMuted()); // isroommuted this.response.appendInt(this.room.getRoomInfo().getWhoCanMuteOption()); this.response.appendInt(this.room.getRoomInfo().getWhoCanKickOption()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java index 62fc89f0..cd015017 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/MuteAllInRoomComposer.java @@ -13,7 +13,7 @@ public class MuteAllInRoomComposer extends MessageComposer { @Override protected ServerMessage composeInternal() { this.response.init(Outgoing.muteAllInRoomComposer); - this.response.appendBoolean(this.room.isMuted()); + this.response.appendBoolean(this.room.getRoomChatManager().isMuted()); return this.response; } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java index 7d75dc76..b534e3f4 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomAdPurchaseInfoComposer.java @@ -13,7 +13,7 @@ public class RoomAdPurchaseInfoComposer extends MessageComposer { public RoomAdPurchaseInfoComposer(List rooms) { for (Room room : rooms) { - if (!room.isPromoted()) + if (!room.getRoomInfo().isPromoted()) this.rooms.add(room); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java index 5d0a6cd1..e95cc45e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/promotions/RoomEventComposer.java @@ -2,7 +2,7 @@ package com.eu.habbo.messages.outgoing.rooms.promotions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomPromotion; +import com.eu.habbo.habbohotel.rooms.promotions.RoomPromotion; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java index 060a0ed6..5e95acfa 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ChatMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java index 0e33a7c4..36c57682 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/ShoutMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java index 83d43b65..4871e28a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/UserNameChangedMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -21,7 +21,7 @@ public class UserNameChangedMessageComposer extends MessageComposer { public UserNameChangedMessageComposer(Habbo habbo, boolean includePrefix) { this.userId = habbo.getHabboInfo().getId(); this.roomId = habbo.getRoomUnit().getVirtualId(); - this.name = (includePrefix ? Room.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getPermissionGroup().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getPermissionGroup().getPrefix()) : "") + habbo.getHabboInfo().getUsername(); + this.name = (includePrefix ? RoomConfiguration.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getPermissionGroup().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getPermissionGroup().getPrefix()) : "") + habbo.getHabboInfo().getUsername(); } @Override diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java index 6bce50a3..00a60fa0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/WhisperMessageComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.rooms.users; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java index 9bc54acf..4d4961f3 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingAcceptComposer.java @@ -1,6 +1,6 @@ package com.eu.habbo.messages.outgoing.trading; -import com.eu.habbo.habbohotel.rooms.RoomTradeUser; +import com.eu.habbo.habbohotel.rooms.trades.RoomTradeUser; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java index aca4e332..88b28ec0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingItemListComposer.java @@ -1,8 +1,8 @@ package com.eu.habbo.messages.outgoing.trading; import com.eu.habbo.habbohotel.items.FurnitureType; -import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.rooms.RoomTradeUser; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTradeUser; import com.eu.habbo.habbohotel.rooms.items.entities.RoomItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java index 8a189406..14fe1bd8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradingOpenComposer.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages.outgoing.trading; -import com.eu.habbo.habbohotel.rooms.RoomTrade; -import com.eu.habbo.habbohotel.rooms.RoomTradeUser; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; +import com.eu.habbo.habbohotel.rooms.trades.RoomTradeUser; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 28b7d0d1..0a7ad840 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -20,6 +20,9 @@ import com.eu.habbo.habbohotel.navigation.EventCategory; import com.eu.habbo.habbohotel.navigation.NavigatorManager; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.constants.RoomConfiguration; +import com.eu.habbo.habbohotel.rooms.trades.RoomTrade; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; @@ -75,8 +78,8 @@ public class PluginManager { Messenger.SAVE_PRIVATE_CHATS = Emulator.getConfig().getBoolean("save.private.chats", false); PacketManager.DEBUG_SHOW_PACKETS = Emulator.getConfig().getBoolean("debug.show.packets"); PacketManager.MULTI_THREADED_PACKET_HANDLING = Emulator.getConfig().getBoolean("io.client.multithreaded.handler"); - Room.HABBO_CHAT_DELAY = Emulator.getConfig().getBoolean("room.chat.delay", false); - Room.MUTEAREA_CAN_WHISPER = Emulator.getConfig().getBoolean("room.chat.mutearea.allow_whisper", false); + RoomConfiguration.HABBO_CHAT_DELAY = Emulator.getConfig().getBoolean("room.chat.delay", false); + RoomConfiguration.MUTEAREA_CAN_WHISPER = Emulator.getConfig().getBoolean("room.chat.mutearea.allow_whisper", false); RoomChatMessage.SAVE_ROOM_CHATS = Emulator.getConfig().getBoolean("save.room.chats", false); RoomLayout.MAXIMUM_STEP_HEIGHT = Emulator.getConfig().getDouble("pathfinder.step.maximum.height", 1.1); RoomLayout.ALLOW_FALLING = Emulator.getConfig().getBoolean("pathfinder.step.allow.falling", true); @@ -98,14 +101,14 @@ public class PluginManager { HabboInventory.MAXIMUM_ITEMS = Emulator.getConfig().getInt("hotel.inventory.max.items"); Messenger.MAXIMUM_FRIENDS = Emulator.getConfig().getInt("hotel.users.max.friends", 300); Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.users.max.friends.hc", 1100); - Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room"); - Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room"); - Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500); - Room.MAXIMUM_POSTITNOTES = Emulator.getConfig().getInt("hotel.room.stickies.max", 200); - Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time"); - Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240); - Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480); - Room.ROLLERS_MAXIMUM_ROLL_AVATARS = Emulator.getConfig().getInt("hotel.room.rollers.roll_avatars.max", 1); + RoomConfiguration.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room"); + RoomConfiguration.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room"); + RoomConfiguration.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500); + RoomConfiguration.MAXIMUM_POSTITNOTES = Emulator.getConfig().getInt("hotel.room.stickies.max", 200); + RoomConfiguration.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time"); + RoomConfiguration.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240); + RoomConfiguration.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480); + RoomConfiguration.ROLLERS_MAXIMUM_ROLL_AVATARS = Emulator.getConfig().getInt("hotel.room.rollers.roll_avatars.max", 1); RoomManager.MAXIMUM_ROOMS_USER = Emulator.getConfig().getInt("hotel.users.max.rooms", 50); RoomManager.MAXIMUM_ROOMS_HC = Emulator.getConfig().getInt("hotel.users.max.rooms.hc", 75); RoomManager.HOME_ROOM_ID = Emulator.getConfig().getInt("hotel.home.room"); @@ -128,7 +131,7 @@ public class PluginManager { } HabboManager.WELCOME_MESSAGE = Emulator.getConfig().getValue("hotel.welcome.alert.message").replace("
", "
").replace("
", "
").replace("\\r", "\r").replace("\\n", "\n").replace("\\t", "\t"); - Room.PREFIX_FORMAT = Emulator.getConfig().getValue("room.chat.prefix.format"); + RoomConfiguration.PREFIX_FORMAT = Emulator.getConfig().getValue("room.chat.prefix.format"); UpdateFloorPropertiesEvent.MAXIMUM_FLOORPLAN_WIDTH_LENGTH = Emulator.getConfig().getInt("hotel.floorplan.max.widthlength"); UpdateFloorPropertiesEvent.MAXIMUM_FLOORPLAN_SIZE = Emulator.getConfig().getInt("hotel.floorplan.max.totalarea"); diff --git a/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java b/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java index 87b40825..37d06bdc 100644 --- a/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/pets/PetTalkEvent.java @@ -1,7 +1,7 @@ package com.eu.habbo.plugin.events.pets; import com.eu.habbo.habbohotel.pets.Pet; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import lombok.Getter; @Getter diff --git a/src/main/java/com/eu/habbo/plugin/events/trading/TradeConfirmEvent.java b/src/main/java/com/eu/habbo/plugin/events/trading/TradeConfirmEvent.java index ee42fd2f..c8359612 100644 --- a/src/main/java/com/eu/habbo/plugin/events/trading/TradeConfirmEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/trading/TradeConfirmEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.plugin.events.trading; -import com.eu.habbo.habbohotel.rooms.RoomTradeUser; +import com.eu.habbo.habbohotel.rooms.trades.RoomTradeUser; import com.eu.habbo.plugin.Event; public class TradeConfirmEvent extends Event { diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java index 8f2a6714..c290584c 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserTalkEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.plugin.events.users; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; import com.eu.habbo.habbohotel.users.Habbo; diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UsernameTalkEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UsernameTalkEvent.java index 4063a93b..62554b42 100644 --- a/src/main/java/com/eu/habbo/plugin/events/users/UsernameTalkEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/users/UsernameTalkEvent.java @@ -1,6 +1,6 @@ package com.eu.habbo.plugin.events.users; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; diff --git a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java index 54bc8a1c..3450f33c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java +++ b/src/main/java/com/eu/habbo/threading/runnables/YouAreAPirate.java @@ -2,7 +2,7 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; +import com.eu.habbo.habbohotel.rooms.chat.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.constants.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.constants.RoomChatType; import com.eu.habbo.habbohotel.users.Habbo; @@ -88,7 +88,7 @@ public class YouAreAPirate implements Runnable { public void run() { if (this.room == this.habbo.getRoomUnit().getRoom()) { if (!iamapirate[this.index].isEmpty()) { - this.room.talk(this.habbo, new RoomChatMessage(iamapirate[this.index], this.habbo, RoomChatMessageBubbles.PIRATE), RoomChatType.SHOUT); + this.room.getRoomChatManager().talk(this.habbo, new RoomChatMessage(iamapirate[this.index], this.habbo, RoomChatMessageBubbles.PIRATE), RoomChatType.SHOUT); } this.index++;