mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Merge branch 'ms4/supernova-room-managers' into 'ms4/supernova'
Various room managers See merge request morningstar/Arcturus-Community!82
This commit is contained in:
commit
0ab52d40af
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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]);
|
||||
|
||||
|
@ -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" +
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<RoomItem> items = new ArrayList<>();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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)) {
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class WiredConditionFurniHaveRoom extends InteractionWiredCondition {
|
||||
|
||||
Collection<Habbo> habbos = room.getRoomUnitManager().getCurrentHabbos().values();
|
||||
Collection<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values();
|
||||
Collection<Pet> pets = room.getRoomUnitManager().getCurrentPets().values();
|
||||
Collection<Pet> pets = room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values();
|
||||
|
||||
return this.getWiredSettings().getItems(room).stream().allMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
|
@ -33,7 +33,7 @@ public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition {
|
||||
|
||||
Collection<Habbo> habbos = room.getRoomUnitManager().getCurrentHabbos().values();
|
||||
Collection<Bot> bots = room.getRoomUnitManager().getRoomBotManager().getCurrentBots().values();
|
||||
Collection<Pet> pets = room.getRoomUnitManager().getCurrentPets().values();
|
||||
Collection<Pet> pets = room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values();
|
||||
|
||||
return this.getWiredSettings().getItems(room).stream().noneMatch(item -> {
|
||||
THashSet<RoomTile> occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
|
@ -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;
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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<Room> getRoomsByScore() {
|
||||
List<Room> 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<Room> 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<Room> getPopularRooms(int count) {
|
||||
@ -1279,7 +1273,8 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
public ArrayList<Room> 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<Room> 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<? extends Game> gameClass) {
|
||||
|
@ -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<Integer, RoomUnit> currentRoomUnits;
|
||||
private final ConcurrentHashMap<Integer, Habbo> currentHabbos;
|
||||
private final ConcurrentHashMap<Integer, Pet> 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<Habbo> 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<Pet> 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<Pet> 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<Pet> toRemovePets = new ArrayList<>();
|
||||
ArrayList<Pet> 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<Pet> 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<Pet> 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<RoomItem> 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());
|
||||
}
|
||||
}
|
||||
|
@ -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<Bot> getBotsAt(RoomTile tile) {
|
||||
return this.currentBots.values().stream().filter(bot -> bot.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet());
|
||||
}
|
||||
public Collection<? extends Bot> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<RoomItem> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
@ -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<Room> SORT_SCORE = Comparator.comparingInt(room -> room.getRoomInfo().getScore());
|
||||
public static final Comparator<Room> SORT_ID = Comparator.comparingInt(room -> room.getRoomInfo().getId());
|
||||
public static final Comparator<Room> 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 = "[<font color=\"%color%\">%prefix%</font>] ";
|
||||
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
|
||||
public static boolean MUTEAREA_CAN_WHISPER = false;
|
||||
}
|
@ -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() {
|
||||
|
@ -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;
|
@ -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<RoomBan> 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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<Integer, Pet> 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<Pet> getPetsAt(RoomTile tile) {
|
||||
return this.currentPets.values().stream().filter(pet -> pet.getRoomUnit().getCurrentPosition().equals(tile)).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Collection<? extends Pet> 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<Pet> 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<Pet> toRemovePets = new ArrayList<>();
|
||||
ArrayList<Pet> 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<RoomPet> cycle() {
|
||||
List<RoomPet> updatedUnits = new ArrayList<>();
|
||||
if (!getCurrentPets().isEmpty() && room.isAllowBotsWalk()) {
|
||||
Iterator<Pet> 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<Pet> 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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;
|
@ -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;
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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<RoomTrade> 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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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<Integer> 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -55,7 +55,7 @@ public class DeleteRoomEvent extends MessageHandler {
|
||||
Emulator.getGameEnvironment().getBotManager().pickUpBot(bot, null, room);
|
||||
}
|
||||
|
||||
List<Pet> pets = new ArrayList<>(room.getRoomUnitManager().getCurrentPets().values());
|
||||
List<Pet> pets = new ArrayList<>(room.getRoomUnitManager().getRoomPetManager().getCurrentPets().values());
|
||||
for (Pet pet : pets) {
|
||||
if (pet instanceof RideablePet rideablePet) {
|
||||
if (rideablePet.getRider() != null) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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")) {
|
||||
|
@ -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));
|
||||
|
@ -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()));
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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()));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<RoomBan> roomBans = new THashSet<>();
|
||||
|
||||
TIntObjectIterator<RoomBan> iterator = this.room.getBannedHabbos().iterator();
|
||||
TIntObjectIterator<RoomBan> 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();
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user