mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 15:36:27 +01:00
Cleaning up Room.java
This commit is contained in:
parent
659a9d375f
commit
c08c57db3c
@ -31,26 +31,37 @@ import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class Bot extends Unit implements Runnable {
|
||||
public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
|
||||
public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
|
||||
|
||||
private final ArrayList<String> chatLines;
|
||||
@Getter
|
||||
@Setter
|
||||
private transient int id;
|
||||
@Getter
|
||||
private String name;
|
||||
@Getter
|
||||
private String motto;
|
||||
@Getter
|
||||
private String figure;
|
||||
@Getter
|
||||
private HabboGender gender;
|
||||
@Getter
|
||||
private int ownerId;
|
||||
@Getter
|
||||
private String ownerName;
|
||||
@Getter
|
||||
@Setter
|
||||
private Room room;
|
||||
@Getter
|
||||
private boolean chatAuto;
|
||||
@Getter
|
||||
private boolean chatRandom;
|
||||
@Getter
|
||||
private short chatDelay;
|
||||
private int chatTimeOut;
|
||||
private int chatTimestamp;
|
||||
private short lastChatIndex;
|
||||
private final int bubble;
|
||||
@Getter
|
||||
private final String type;
|
||||
@Getter
|
||||
private int effect;
|
||||
private transient boolean canWalk = true;
|
||||
private boolean needsUpdate;
|
||||
@ -59,6 +70,10 @@ public class Bot extends Unit implements Runnable {
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
private RoomBot roomUnit;
|
||||
public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
|
||||
public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
|
||||
@Getter
|
||||
private final ArrayList<String> chatLines;
|
||||
|
||||
public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) {
|
||||
this.id = id;
|
||||
@ -193,7 +208,7 @@ public class Bot extends Unit implements Runnable {
|
||||
|
||||
String message = this.chatLines.get(this.lastChatIndex)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getRoomInfo().getOwnerInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.itemCount() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.getRoomItemManager().getCurrentItems().size() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getRoomInfo().getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getRoomUnitManager().getRoomHabbosCount() + "");
|
||||
@ -251,7 +266,7 @@ public class Bot extends Unit implements Runnable {
|
||||
|
||||
public void onPlace(Habbo habbo, Room room) {
|
||||
if (this.getRoomUnit() != null) {
|
||||
room.giveEffect(this.getRoomUnit(), this.effect, -1);
|
||||
this.getRoomUnit().giveEffect(this.effect, -1);
|
||||
}
|
||||
|
||||
if(PLACEMENT_MESSAGES.length > 0) {
|
||||
@ -270,18 +285,6 @@ public class Bot extends Unit implements Runnable {
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getBubbleId() {
|
||||
return bubble;
|
||||
}
|
||||
@ -294,19 +297,11 @@ public class Bot extends Unit implements Runnable {
|
||||
//this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose());
|
||||
}
|
||||
|
||||
public String getMotto() {
|
||||
return this.motto;
|
||||
}
|
||||
|
||||
public void setMotto(String motto) {
|
||||
this.motto = motto;
|
||||
this.needsUpdate = true;
|
||||
}
|
||||
|
||||
public String getFigure() {
|
||||
return this.figure;
|
||||
}
|
||||
|
||||
public void setFigure(String figure) {
|
||||
this.figure = figure;
|
||||
this.needsUpdate = true;
|
||||
@ -315,10 +310,6 @@ public class Bot extends Unit implements Runnable {
|
||||
this.room.sendComposer(new RoomUsersComposer(this).compose());
|
||||
}
|
||||
|
||||
public HabboGender getGender() {
|
||||
return this.gender;
|
||||
}
|
||||
|
||||
public void setGender(HabboGender gender) {
|
||||
this.gender = gender;
|
||||
this.needsUpdate = true;
|
||||
@ -327,10 +318,6 @@ public class Bot extends Unit implements Runnable {
|
||||
this.room.sendComposer(new RoomUsersComposer(this).compose());
|
||||
}
|
||||
|
||||
public int getOwnerId() {
|
||||
return this.ownerId;
|
||||
}
|
||||
|
||||
public void setOwnerId(int ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
this.needsUpdate = true;
|
||||
@ -339,10 +326,6 @@ public class Bot extends Unit implements Runnable {
|
||||
this.room.sendComposer(new RoomUsersComposer(this).compose());
|
||||
}
|
||||
|
||||
public String getOwnerName() {
|
||||
return this.ownerName;
|
||||
}
|
||||
|
||||
public void setOwnerName(String ownerName) {
|
||||
this.ownerName = ownerName;
|
||||
this.needsUpdate = true;
|
||||
@ -351,27 +334,11 @@ public class Bot extends Unit implements Runnable {
|
||||
this.room.sendComposer(new RoomUsersComposer(this).compose());
|
||||
}
|
||||
|
||||
public Room getRoom() {
|
||||
return this.room;
|
||||
}
|
||||
|
||||
public void setRoom(Room room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public boolean isChatAuto() {
|
||||
return this.chatAuto;
|
||||
}
|
||||
|
||||
public void setChatAuto(boolean chatAuto) {
|
||||
this.chatAuto = chatAuto;
|
||||
this.needsUpdate = true;
|
||||
}
|
||||
|
||||
public boolean isChatRandom() {
|
||||
return this.chatRandom;
|
||||
}
|
||||
|
||||
public void setChatRandom(boolean chatRandom) {
|
||||
this.chatRandom = chatRandom;
|
||||
this.needsUpdate = true;
|
||||
@ -381,10 +348,6 @@ public class Bot extends Unit implements Runnable {
|
||||
return !this.chatLines.isEmpty();
|
||||
}
|
||||
|
||||
public int getChatDelay() {
|
||||
return this.chatDelay;
|
||||
}
|
||||
|
||||
public void setChatDelay(short chatDelay) {
|
||||
this.chatDelay = (short) Math.min(Math.max(chatDelay, BotManager.MINIMUM_CHAT_SPEED), BotManager.MAXIMUM_CHAT_SPEED);
|
||||
this.needsUpdate = true;
|
||||
@ -402,21 +365,13 @@ public class Bot extends Unit implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getEffect() {
|
||||
return this.effect;
|
||||
}
|
||||
|
||||
public void setEffect(int effect, int duration) {
|
||||
this.effect = effect;
|
||||
this.needsUpdate = true;
|
||||
|
||||
if (this.getRoomUnit() != null) {
|
||||
if (this.room != null) {
|
||||
this.room.giveEffect(this.getRoomUnit(), this.effect, duration);
|
||||
this.getRoomUnit().giveEffect(this.effect, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -435,10 +390,6 @@ public class Bot extends Unit implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getChatLines() {
|
||||
return this.chatLines;
|
||||
}
|
||||
|
||||
public int getFollowingHabboId() {
|
||||
return this.followingHabboId;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class EnableCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
target.getRoomUnit().getRoom().giveEffect(target, effectId, -1);
|
||||
target.getRoomUnit().giveEffect(effectId, -1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Caught exception", e);
|
||||
|
@ -11,7 +11,7 @@ public class HabnamCommand extends Command {
|
||||
@Override
|
||||
public boolean handle(GameClient gameClient, String[] params) {
|
||||
if (gameClient.getHabbo().getHabboStats().hasActiveClub() && gameClient.getHabbo().getRoomUnit().getRoom() != null) {
|
||||
gameClient.getHabbo().getRoomUnit().getRoom().giveEffect(gameClient.getHabbo(), 140, 30);
|
||||
gameClient.getHabbo().getRoomUnit().giveEffect(140, 30);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class MoonwalkCommand extends Command {
|
||||
if (gameClient.getHabbo().getRoomUnit().getEffectId() == 136)
|
||||
effect = 0;
|
||||
|
||||
gameClient.getHabbo().getRoomUnit().getRoom().giveEffect(gameClient.getHabbo(), effect, -1);
|
||||
gameClient.getHabbo().getRoomUnit().giveEffect(effect, -1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class RoomEffectCommand extends Command {
|
||||
|
||||
if (effectId >= 0) {
|
||||
Room room = gameClient.getHabbo().getRoomUnit().getRoom();
|
||||
room.getRoomUnitManager().getRoomHabbos().forEach(habbo -> room.giveEffect(habbo, effectId, -1));
|
||||
room.getRoomUnitManager().getRoomHabbos().forEach(habbo -> habbo.getRoomUnit().giveEffect(effectId, -1));
|
||||
|
||||
} else {
|
||||
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT);
|
||||
|
@ -27,7 +27,7 @@ public class BattleBanzaiGameTeam extends GameTeam {
|
||||
roomHabbo.setPreviousEffectEndTimestamp(roomHabbo.getPreviousEffectEndTimestamp());
|
||||
}
|
||||
|
||||
gamePlayer.getHabbo().getRoomUnit().getRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1, true);
|
||||
gamePlayer.getHabbo().getRoomUnit().giveEffect(BattleBanzaiGame.effectId + this.teamColor.type, -1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,12 +56,12 @@ public class BattleBanzaiGameTeam extends GameTeam {
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
|
||||
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
|
||||
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
|
||||
}
|
||||
|
||||
roomUnit.setCanWalk(true);
|
||||
|
@ -208,6 +208,6 @@ public class FreezeGamePlayer extends GamePlayer {
|
||||
if (this.dead)
|
||||
return;
|
||||
|
||||
super.getHabbo().getRoomUnit().getRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1, true);
|
||||
super.getHabbo().getRoomUnit().giveEffect(this.correctEffectId(), -1, true);
|
||||
}
|
||||
}
|
||||
|
@ -44,12 +44,12 @@ public class FreezeGameTeam extends GameTeam {
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
|
||||
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
|
||||
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
|
||||
}
|
||||
|
||||
roomUnit.setCanWalk(true);
|
||||
@ -68,6 +68,6 @@ public class FreezeGameTeam extends GameTeam {
|
||||
RoomHabbo roomHabbo = gamePlayer.getHabbo().getRoomUnit();
|
||||
if (roomHabbo.getEffectId() > 0)
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
gamePlayer.getHabbo().getRoomUnit().getRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1, true);
|
||||
gamePlayer.getHabbo().getRoomUnit().giveEffect(FreezeGame.effectId + this.teamColor.type, -1, true);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public abstract class TagGame extends Game {
|
||||
|
||||
THashSet<RoomItem> poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole());
|
||||
InteractionTagPole pole = this.taggers.get(tagger);
|
||||
room.giveEffect(tagged, this.getTaggedEffect(tagged), -1);
|
||||
tagged.getRoomUnit().giveEffect(this.getTaggedEffect(tagged), -1);
|
||||
|
||||
if (poles.size() > this.taggers.size()) {
|
||||
for (Map.Entry<Habbo, InteractionTagPole> set : this.taggers.entrySet()) {
|
||||
@ -108,12 +108,12 @@ public abstract class TagGame extends Game {
|
||||
}
|
||||
|
||||
for (RoomItem item : poles) {
|
||||
tagged.getRoomUnit().getRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1);
|
||||
tagged.getRoomUnit().giveEffect(this.getTaggedEffect(tagged), -1);
|
||||
this.taggers.put(tagged, (InteractionTagPole) item);
|
||||
}
|
||||
} else {
|
||||
if (tagger != null) {
|
||||
room.giveEffect(tagger, this.getEffect(tagger), -1);
|
||||
tagger.getRoomUnit().giveEffect(this.getEffect(tagger), -1);
|
||||
this.taggers.remove(tagger);
|
||||
}
|
||||
|
||||
@ -145,8 +145,8 @@ public abstract class TagGame extends Game {
|
||||
RoomItem item = iterator.next();
|
||||
if (roomHabbo.getEffectId() > 0)
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
|
||||
this.room.scheduledTasks.add(() -> habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true));
|
||||
habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true);
|
||||
this.room.scheduledTasks.add(() -> habbo.getRoomUnit().giveEffect(this.getTaggedEffect(habbo), -1, true));
|
||||
this.taggers.put(habbo, (InteractionTagPole) item);
|
||||
return true;
|
||||
}
|
||||
@ -155,15 +155,15 @@ public abstract class TagGame extends Game {
|
||||
if (this.taggers.isEmpty()) {
|
||||
if (roomHabbo.getEffectId() > 0)
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
|
||||
this.room.scheduledTasks.add(() -> habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true));
|
||||
habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true);
|
||||
this.room.scheduledTasks.add(() -> habbo.getRoomUnit().giveEffect(this.getTaggedEffect(habbo), -1, true));
|
||||
this.taggers.put(habbo, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (roomHabbo.getEffectId() > 0)
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
habbo.getRoomUnit().getRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
|
||||
habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -192,12 +192,12 @@ public abstract class TagGame extends Game {
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
|
||||
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
|
||||
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import com.eu.habbo.habbohotel.games.*;
|
||||
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
@ -35,14 +34,14 @@ public class WiredGame extends Game {
|
||||
RoomHabbo roomHabbo = habbo.getRoomUnit();
|
||||
if (roomHabbo.getEffectId() > 0)
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1, true);
|
||||
roomHabbo.giveEffect(FreezeGame.effectId + teamColor.type, -1, true);
|
||||
return super.addHabbo(habbo, teamColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHabbo(Habbo habbo) {
|
||||
super.removeHabbo(habbo);
|
||||
RoomUnit roomUnit = habbo.getRoomUnit();
|
||||
RoomHabbo roomUnit = habbo.getRoomUnit();
|
||||
Room room = this.room;
|
||||
if (room == null) return;
|
||||
|
||||
@ -61,12 +60,12 @@ public class WiredGame extends Game {
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
|
||||
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
|
||||
roomUnit.giveEffect(nextEffectM, nextEffectDuration, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
|
||||
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
|
||||
roomUnit.giveEffect(nextEffectF, nextEffectDuration, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
|
||||
THashSet<RoomItem> tileItems = room.getItemsAt(tile);
|
||||
for (RoomItem tileItem : tileItems) {
|
||||
if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
|
||||
room.pickUpItem(tileItem, null);
|
||||
room.getRoomItemManager().pickUpItem(tileItem, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
|
||||
if (newTiles.contains(tile)) continue;
|
||||
for (RoomItem tileItem : tileItems) {
|
||||
if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
|
||||
room.pickUpItem(tileItem, null);
|
||||
room.getRoomItemManager().pickUpItem(tileItem, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
|
||||
THashSet<RoomItem> tileItems = room.getItemsAt(tile);
|
||||
for (RoomItem tileItem : tileItems) {
|
||||
if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
|
||||
room.pickUpItem(tileItem, null);
|
||||
room.getRoomItemManager().pickUpItem(tileItem, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
@ -108,39 +109,46 @@ public class InteractionDefault extends RoomItem {
|
||||
return;
|
||||
}
|
||||
|
||||
if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) {
|
||||
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
|
||||
if (roomUnit instanceof RoomHabbo roomHabbo) {
|
||||
Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomHabbo);
|
||||
|
||||
if (habbo == null) return;
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
if (((RoomAvatar) roomUnit).getEffectId() > 0)
|
||||
roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
if (roomHabbo.getEffectId() > 0) {
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
}
|
||||
|
||||
roomHabbo.giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
if (((RoomAvatar) roomUnit).getEffectId() > 0)
|
||||
roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
if (roomHabbo.getEffectId() > 0) {
|
||||
roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
|
||||
}
|
||||
roomHabbo.giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
} else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) {
|
||||
Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId());
|
||||
} else if (roomUnit instanceof RoomBot roomBot) {
|
||||
Bot bot = room.getRoomUnitManager().getBotByRoomUnit(roomBot);
|
||||
|
||||
if (bot == null) return;
|
||||
|
||||
if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && ((RoomAvatar) roomUnit).getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
if (((RoomAvatar) roomUnit).getEffectId() > 0)
|
||||
roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
|
||||
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1);
|
||||
if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomBot.getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
if (roomBot.getEffectId() > 0) {
|
||||
roomBot.setPreviousEffectId(roomBot.getEffectId(), roomBot.getPreviousEffectEndTimestamp());
|
||||
}
|
||||
|
||||
roomBot.giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && ((RoomAvatar) roomUnit).getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
if (((RoomAvatar) roomUnit).getEffectId() > 0)
|
||||
roomUnit.setPreviousEffectId(((RoomAvatar) roomUnit).getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
|
||||
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1);
|
||||
if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomBot.getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
if (roomBot.getEffectId() > 0) {
|
||||
roomUnit.setPreviousEffectId(roomBot.getEffectId(), roomBot.getPreviousEffectEndTimestamp());
|
||||
}
|
||||
|
||||
roomBot.giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,12 +188,12 @@ public class InteractionDefault extends RoomItem {
|
||||
if (habbo != null) {
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(habbo, nextEffectM, nextEffectDuration);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(habbo, nextEffectF, nextEffectDuration);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration);
|
||||
}
|
||||
}
|
||||
} else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) {
|
||||
@ -193,12 +201,12 @@ public class InteractionDefault extends RoomItem {
|
||||
|
||||
if (bot != null) {
|
||||
if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(roomUnit, nextEffectM, nextEffectDuration);
|
||||
bot.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(roomUnit, nextEffectF, nextEffectDuration);
|
||||
bot.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomLayout;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -38,7 +39,10 @@ public class InteractionEffectGiver extends InteractionDefault {
|
||||
if (!this.getExtradata().equals("0")) return;
|
||||
|
||||
RoomItem instance = this;
|
||||
room.giveEffect(roomUnit, this.getBaseItem().getRandomVendingItem(), -1);
|
||||
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar) {
|
||||
roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getStateCount() > 1) {
|
||||
this.setExtradata("1");
|
||||
|
@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
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 com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||
@ -67,10 +68,12 @@ public class InteractionEffectTile extends InteractionPressurePlate {
|
||||
}
|
||||
|
||||
private void giveEffect(Room room, RoomUnit roomUnit, HabboGender gender) {
|
||||
if (gender.equals(HabboGender.M)) {
|
||||
room.giveEffect(roomUnit, this.getBaseItem().getEffectM(), -1);
|
||||
} else {
|
||||
room.giveEffect(roomUnit, this.getBaseItem().getEffectF(), -1);
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar) {
|
||||
if (gender.equals(HabboGender.M)) {
|
||||
roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
} else {
|
||||
roomAvatar.giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,6 @@ public class InteractionEffectVendingMachine extends InteractionVendingMachine {
|
||||
|
||||
@Override
|
||||
public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) {
|
||||
room.giveEffect(roomAvatar, this.getBaseItem().getRandomVendingItem(), 30);
|
||||
roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), 30);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ public class InteractionEffectVendingMachineNoSides extends InteractionVendingMa
|
||||
|
||||
@Override
|
||||
public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) {
|
||||
room.giveEffect(roomAvatar, this.getBaseItem().getRandomVendingItem(), 30);
|
||||
roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
|
||||
@ -86,12 +87,12 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
|
||||
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
|
||||
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -164,7 +165,11 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
|
||||
private void setEffect(Room room, int effectId) {
|
||||
if (this.roomUnitId == -1) return;
|
||||
|
||||
room.giveEffect(this.getCurrentRoomUnit(room), effectId, -1);
|
||||
RoomUnit roomUnit = this.getCurrentRoomUnit(room);
|
||||
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar) {
|
||||
roomAvatar.giveEffect(effectId, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void reset(Room room) {
|
||||
|
@ -114,12 +114,12 @@ public class InteractionMultiHeight extends RoomItem {
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,12 +136,12 @@ public class InteractionMultiHeight extends RoomItem {
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
habbo.getRoomUnit().giveEffect(0, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
habbo.getRoomUnit().giveEffect(0, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class InteractionRentableSpace extends RoomItem {
|
||||
|
||||
for (RoomItem item : items) {
|
||||
if (item.getUserId() == this.renterId) {
|
||||
room.pickUpItem(item, null);
|
||||
room.getRoomItemManager().pickUpItem(item, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
room.giveEffect(roomUnit, 97, -1);
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar) {
|
||||
roomAvatar.giveEffect(97, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,7 +38,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
|
||||
if (roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.getEffectId() == 97) {
|
||||
room.giveEffect(roomAvatar, 0, -1);
|
||||
roomAvatar.giveEffect(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +72,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
|
||||
public void onPickUp(Room room) {
|
||||
for (Habbo habbo : room.getHabbosOnItem(this)) {
|
||||
if (habbo.getRoomUnit().getEffectId() == 97) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
habbo.getRoomUnit().giveEffect(0, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,7 +83,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
|
||||
|
||||
for (Habbo habbo : room.getHabbosOnItem(this)) {
|
||||
if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY())) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
habbo.getRoomUnit().giveEffect(0, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class InteractionTileEffectProvider extends InteractionCustomValues {
|
||||
room.updateItem(proxy);
|
||||
}, 500);
|
||||
|
||||
room.giveEffect(roomHabbo, effectId, -1);
|
||||
roomHabbo.giveEffect(effectId, -1);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
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.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
|
||||
@ -35,24 +35,24 @@ public class InteractionTrap extends InteractionDefault {
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
||||
if (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO)) {
|
||||
if (roomUnit instanceof RoomHabbo roomHabbo) {
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
roomHabbo.giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
roomHabbo.giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
roomUnit.setCanWalk(false);
|
||||
roomHabbo.setCanWalk(false);
|
||||
Emulator.getThreading().run(() -> {
|
||||
room.giveEffect(roomUnit, 0, -1);
|
||||
roomHabbo.giveEffect(0, -1);
|
||||
roomUnit.setCanWalk(true);
|
||||
room.giveEffect(roomUnit, effect, -1);
|
||||
roomHabbo.giveEffect(effect, -1);
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
|
@ -95,9 +95,9 @@ public class InteractionVendingMachine extends RoomItem {
|
||||
giveVendingMachineItem(room, roomAvatar);
|
||||
|
||||
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
|
||||
client.getHabbo().getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
|
||||
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
|
||||
client.getHabbo().getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
|
||||
Emulator.getThreading().run(this, 500);
|
||||
}, 1500);
|
||||
|
@ -41,7 +41,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.getRoomItemManager().getCurrentItems().size() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + "");
|
||||
|
@ -41,7 +41,7 @@ public class WiredEffectBotTalkToRoom extends InteractionWiredEffect {
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.getRoomItemManager().getCurrentItems().size() + "")
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName)
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName())
|
||||
.replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + "");
|
||||
|
@ -87,7 +87,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
|
||||
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue());
|
||||
int count = 1;
|
||||
while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.tileWalkable(targetTile) || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) {
|
||||
while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.tileWalkable(targetTile) || room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) {
|
||||
setting.setDirection(this.nextDirection(setting.getDirection()));
|
||||
|
||||
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue());
|
||||
@ -103,10 +103,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
RoomTile newTargetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirectionValue);
|
||||
|
||||
if(item.getRotation() != setting.getRotation()) {
|
||||
if(room.furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE)
|
||||
if(room.getRoomItemManager().furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE)
|
||||
continue;
|
||||
|
||||
room.moveFurniTo(item, newTargetTile, setting.getRotation(), null, true);
|
||||
room.getRoomItemManager().moveFurniTo(item, newTargetTile, setting.getRotation(), null, true, true);
|
||||
}
|
||||
|
||||
boolean hasRoomUnits = false;
|
||||
@ -122,11 +122,11 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
if (!hasRoomUnits) {
|
||||
RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY());
|
||||
double oldZ = item.getZ();
|
||||
if(room.moveFurniTo(item, newTargetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) {
|
||||
if (room.getRoomItemManager().moveFurniTo(item, newTargetTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -30,9 +31,11 @@ public class WiredEffectGiveEffect extends WiredEffectWhisper {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (effectId >= 0) {
|
||||
room.giveEffect(roomUnit, effectId, Integer.MAX_VALUE);
|
||||
return true;
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar) {
|
||||
if (effectId >= 0) {
|
||||
roomAvatar.giveEffect(effectId, Integer.MAX_VALUE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -43,7 +43,7 @@ public class WiredEffectKickRoom extends InteractionWiredEffect {
|
||||
return true;
|
||||
}
|
||||
|
||||
room.giveEffect(habbo, 4, 2);
|
||||
habbo.getRoomUnit().giveEffect(4, 2);
|
||||
|
||||
if (!this.getWiredSettings().getStringParam().isEmpty()) {
|
||||
habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(this.getWiredSettings().getStringParam(), habbo, habbo, RoomChatMessageBubbles.ALERT)));
|
||||
|
@ -3,9 +3,12 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
@ -63,8 +66,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
double oldZ = item.getZ();
|
||||
|
||||
if(rotation && !position) {
|
||||
if(item.getRotation() != furniSettings.getRotation() && room.furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
room.moveFurniTo(item, oldLocation, furniSettings.getRotation(), null, true);
|
||||
if (item.getRotation() != furniSettings.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, item, furniSettings.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
room.getRoomItemManager().moveFurniTo(item, oldLocation, furniSettings.getRotation(), null, true, true);
|
||||
}
|
||||
}
|
||||
else if(position) {
|
||||
@ -72,9 +75,10 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
|
||||
RoomTile newLocation = room.getLayout().getTile((short) furniSettings.getX(), (short) furniSettings.getY());
|
||||
int newRotation = rotation ? furniSettings.getRotation() : item.getRotation();
|
||||
|
||||
if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) {
|
||||
if(room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) {
|
||||
if(slideAnimation) {
|
||||
if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, true) == FurnitureMovementError.NONE) {
|
||||
boolean sendUpdates = !slideAnimation;
|
||||
if (room.getRoomItemManager().moveFurniTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) {
|
||||
if (slideAnimation) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
|
||||
RoomTile oldLocation = room.getLayout().getTile(item.getX(), item.getY());
|
||||
double oldZ = item.getZ();
|
||||
|
||||
if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) {
|
||||
if(room.moveFurniTo(item, newLocation, item.getRotation(), null, false) == FurnitureMovementError.NONE) {
|
||||
if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && newLocation != oldLocation && room.getRoomItemManager().furnitureFitsAt(newLocation, item, item.getRotation(), true) == FurnitureMovementError.NONE) {
|
||||
if (room.getRoomItemManager().moveFurniTo(item, newLocation, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
if (!layout.tileExists(tile.getX(), tile.getY()))
|
||||
continue;
|
||||
|
||||
if (room.furnitureFitsAt(tile, item, item.getRotation()) == FurnitureMovementError.INVALID_MOVE)
|
||||
if (room.getRoomItemManager().furnitureFitsAt(tile, item, item.getRotation(), true) == FurnitureMovementError.INVALID_MOVE)
|
||||
continue;
|
||||
|
||||
RoomItem topItem = room.getTopItemAt(tile.getX(), tile.getY());
|
||||
@ -200,8 +200,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
|
||||
|
||||
if(newTile != null) {
|
||||
lastDirections.put(item.getId(), moveDirection);
|
||||
if(newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) {
|
||||
if (room.moveFurniTo(item, newTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) {
|
||||
if (newTile.getState() != RoomTileState.INVALID && newTile != oldLocation && room.getRoomItemManager().furnitureFitsAt(newTile, item, item.getRotation(), true) == FurnitureMovementError.NONE) {
|
||||
if (room.getRoomItemManager().moveFurniTo(item, newTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newTile, item.getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,13 @@ import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.ICycleable;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTileState;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
@ -63,11 +66,14 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
|
||||
|
||||
boolean slideAnimation = item.getRotation() == newRotation;
|
||||
|
||||
FurnitureMovementError furniMoveTest = room.furnitureFitsAt(newLocation, item, newRotation, true);
|
||||
FurnitureMovementError furniMoveTest = room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, true);
|
||||
if(newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != item.getRotation()) && (furniMoveTest == FurnitureMovementError.NONE || ((furniMoveTest == FurnitureMovementError.TILE_HAS_BOTS || furniMoveTest == FurnitureMovementError.TILE_HAS_HABBOS || furniMoveTest == FurnitureMovementError.TILE_HAS_PETS) && newLocation == oldLocation))) {
|
||||
if(room.furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE && room.moveFurniTo(item, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE) {
|
||||
if(slideAnimation) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose());
|
||||
if(room.getRoomItemManager().furnitureFitsAt(newLocation, item, newRotation, false) == FurnitureMovementError.NONE) {
|
||||
boolean sendUpdates = !slideAnimation;
|
||||
if (room.getRoomItemManager().moveFurniTo(item, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE) {
|
||||
if (slideAnimation) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, newLocation, item.getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorComposer;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.HabboBroadcastMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
|
||||
import com.eu.habbo.messages.outgoing.polls.infobus.QuestionAnsweredComposer;
|
||||
import com.eu.habbo.messages.outgoing.polls.infobus.QuestionComposer;
|
||||
@ -53,7 +52,8 @@ import com.eu.habbo.messages.outgoing.rooms.items.*;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.*;
|
||||
import com.eu.habbo.messages.outgoing.users.RemainingMutePeriodComposer;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
import com.eu.habbo.plugin.events.furniture.*;
|
||||
import com.eu.habbo.plugin.events.furniture.FurnitureRolledEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.FurnitureStackHeightEvent;
|
||||
import com.eu.habbo.plugin.events.rooms.RoomLoadedEvent;
|
||||
import com.eu.habbo.plugin.events.rooms.RoomUnloadedEvent;
|
||||
import com.eu.habbo.plugin.events.rooms.RoomUnloadingEvent;
|
||||
@ -72,7 +72,6 @@ import io.netty.util.internal.ConcurrentSet;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.math3.util.Pair;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.Connection;
|
||||
@ -153,6 +152,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
@Getter
|
||||
@Setter
|
||||
private volatile boolean allowBotsWalk;
|
||||
@Getter
|
||||
@Setter
|
||||
private volatile boolean allowEffects;
|
||||
@Getter
|
||||
@ -322,8 +322,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
log.error(CAUGHT_EXCEPTION, e);
|
||||
}
|
||||
|
||||
if (this.itemCount() > Room.MAXIMUM_FURNI) {
|
||||
log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.roomInfo.getId(), this.itemCount(), Room.MAXIMUM_FURNI);
|
||||
if (this.getRoomItemManager().getCurrentItems().size() > Room.MAXIMUM_FURNI) {
|
||||
log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.roomInfo.getId(), this.getRoomItemManager().getCurrentItems().size(), Room.MAXIMUM_FURNI);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,11 +361,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.sendComposer(new HeightMapUpdateMessageComposer(this, tiles).compose());
|
||||
}
|
||||
|
||||
private RoomTileState calculateTileState(RoomTile tile) {
|
||||
public RoomTileState calculateTileState(RoomTile tile) {
|
||||
return this.calculateTileState(tile, null);
|
||||
}
|
||||
|
||||
private RoomTileState calculateTileState(RoomTile tile, RoomItem exclude) {
|
||||
public RoomTileState calculateTileState(RoomTile tile, RoomItem exclude) {
|
||||
if (tile == null || tile.getState() == RoomTileState.INVALID)
|
||||
return RoomTileState.INVALID;
|
||||
|
||||
@ -427,59 +427,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return walkable;
|
||||
}
|
||||
|
||||
public void pickUpItem(RoomItem item, Habbo picker) {
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePickedUpEvent.class, true)) {
|
||||
Event furniturePickedUpEvent = new FurniturePickedUpEvent(item, picker);
|
||||
Emulator.getPluginManager().fireEvent(furniturePickedUpEvent);
|
||||
|
||||
if (furniturePickedUpEvent.isCancelled())
|
||||
return;
|
||||
}
|
||||
|
||||
this.removeHabboItem(item);
|
||||
item.onPickUp(this);
|
||||
item.setRoomId(0);
|
||||
item.needsUpdate(true);
|
||||
|
||||
if (item.getBaseItem().getType() == FurnitureType.FLOOR) {
|
||||
this.sendComposer(new RemoveFloorItemComposer(item).compose());
|
||||
|
||||
THashSet<RoomTile> updatedTiles = new THashSet<>();
|
||||
Rectangle rectangle = RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
|
||||
for (short x = (short) rectangle.x; x < rectangle.x + rectangle.getWidth(); x++) {
|
||||
for (short y = (short) rectangle.y; y < rectangle.y + rectangle.getHeight(); y++) {
|
||||
double stackHeight = this.getStackHeight(x, y, false);
|
||||
RoomTile tile = this.layout.getTile(x, y);
|
||||
|
||||
if (tile != null) {
|
||||
tile.setStackHeight(stackHeight);
|
||||
updatedTiles.add(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.sendComposer(new HeightMapUpdateMessageComposer(this, updatedTiles).compose());
|
||||
this.updateTiles(updatedTiles);
|
||||
updatedTiles.forEach(tile -> {
|
||||
this.updateHabbosAt(tile);
|
||||
this.updateBotsAt(tile.getX(), tile.getY());
|
||||
});
|
||||
} else if (item.getBaseItem().getType() == FurnitureType.WALL) {
|
||||
this.sendComposer(new ItemRemoveMessageComposer(item).compose());
|
||||
}
|
||||
|
||||
Habbo habbo = (picker != null && picker.getHabboInfo().getId() == item.getId() ? picker : Emulator.getGameServer().getGameClientManager().getHabbo(item.getUserId()));
|
||||
if (habbo != null) {
|
||||
habbo.getInventory().getItemsComponent().addItem(item);
|
||||
habbo.getClient().sendResponse(new UnseenItemsComposer(item));
|
||||
habbo.getClient().sendResponse(new FurniListInvalidateComposer());
|
||||
}
|
||||
Emulator.getThreading().run(item);
|
||||
}
|
||||
|
||||
public void updateHabbo(Habbo habbo) {
|
||||
this.updateRoomUnit(habbo.getRoomUnit());
|
||||
}
|
||||
@ -572,7 +519,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
bot.getRoomUnit().setCurrentZ(topItem.getZ() + Item.getCurrentHeight(topItem));
|
||||
|
||||
if (topItem.getBaseItem().allowLay()) {
|
||||
bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + "");
|
||||
bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, String.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -854,7 +801,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
*/
|
||||
|
||||
if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) {
|
||||
this.giveEffect(habbo, 0, -1);
|
||||
habbo.getRoomUnit().giveEffect(0, -1)
|
||||
}
|
||||
|
||||
if (habbo.getRoomUnit().isKicked()) {
|
||||
@ -1303,7 +1250,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if(unit instanceof RoomAvatar roomAvatar) {
|
||||
roomAvatar.setDance(DanceType.NONE);
|
||||
}
|
||||
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + "");
|
||||
unit.setStatus(RoomUnitStatus.SIT, String.valueOf(Item.getCurrentHeight(topItem)));
|
||||
unit.setCurrentZ(topItem.getZ());
|
||||
unit.setRotation(RoomRotation.values()[topItem.getRotation()]);
|
||||
unit.setSitUpdate(false);
|
||||
@ -1322,7 +1269,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
} else {
|
||||
if (!unit.hasStatus(RoomUnitStatus.LAY)) {
|
||||
unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) + "");
|
||||
unit.setStatus(RoomUnitStatus.LAY, String.valueOf(Item.getCurrentHeight(topItem)));
|
||||
unit.setRotation(RoomRotation.values()[topItem.getRotation() % 4]);
|
||||
|
||||
if (topItem.getRotation() == 0 || topItem.getRotation() == 4) {
|
||||
@ -2783,7 +2730,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new YouAreControllerMessageComposer(flatCtrl));
|
||||
habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, flatCtrl.getLevel() + "");
|
||||
habbo.getRoomUnit().setStatus(RoomUnitStatus.FLAT_CONTROL, String.valueOf(flatCtrl.getLevel()));
|
||||
habbo.getRoomUnit().setRightsLevel(flatCtrl);
|
||||
habbo.getRoomUnit().setStatusUpdateNeeded(true);
|
||||
|
||||
@ -2867,46 +2814,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void giveEffect(Habbo habbo, int effectId, int duration, boolean ignoreChecks) {
|
||||
if (habbo != null && habbo.getRoomUnit() != null && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())) {
|
||||
this.giveEffect(habbo.getRoomUnit(), effectId, duration, ignoreChecks);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveEffect(Habbo habbo, int effectId, int duration) {
|
||||
if (habbo != null && habbo.getRoomUnit() != null && this.roomUnitManager.getCurrentRoomHabbos().containsKey(habbo.getHabboInfo().getId())) {
|
||||
this.giveEffect(habbo.getRoomUnit(), effectId, duration, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveEffect(RoomUnit roomUnit, int effectId, int duration) {
|
||||
this.giveEffect(roomUnit, effectId, duration, false);
|
||||
}
|
||||
|
||||
public void giveEffect(RoomUnit roomUnit, int effectId, int duration, boolean ignoreChecks) {
|
||||
if (roomUnit == null || !roomUnit.isInRoom() || !(roomUnit instanceof RoomAvatar roomAvatar)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Habbo habbo = this.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
|
||||
|
||||
if (roomAvatar.getRoomUnitType() == RoomUnitType.HABBO && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (duration == -1 || duration == Integer.MAX_VALUE) {
|
||||
duration = Integer.MAX_VALUE;
|
||||
} else {
|
||||
duration += Emulator.getIntUnixTimestamp();
|
||||
}
|
||||
|
||||
if ((this.allowEffects || ignoreChecks) && !roomAvatar.isSwimming()) {
|
||||
roomAvatar.setEffectId(effectId);
|
||||
roomAvatar.setEffectEndTimestamp(duration);
|
||||
this.sendComposer(new AvatarEffectMessageComposer(roomAvatar).compose());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateItem(RoomItem item) {
|
||||
if (!this.isLoaded()) {
|
||||
return;
|
||||
@ -2981,12 +2888,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
for (RoomItem i : items) {
|
||||
this.pickUpItem(i, null);
|
||||
this.getRoomItemManager().pickUpItem(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void ejectUserItem(RoomItem item) {
|
||||
this.pickUpItem(item, null);
|
||||
this.getRoomItemManager().pickUpItem(item, null);
|
||||
}
|
||||
|
||||
public void ejectAll() {
|
||||
@ -3018,7 +2925,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
for (Map.Entry<Integer, THashSet<RoomItem>> entrySet : userItemsMap.entrySet()) {
|
||||
for (RoomItem i : entrySet.getValue()) {
|
||||
this.pickUpItem(i, null);
|
||||
this.getRoomItemManager().pickUpItem(i, null);
|
||||
}
|
||||
|
||||
Habbo user = Emulator.getGameEnvironment().getHabboManager().getHabbo(entrySet.getKey());
|
||||
@ -3165,10 +3072,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.sendComposer(new HabboBroadcastMessageComposer(message).compose());
|
||||
}
|
||||
|
||||
public int itemCount() {
|
||||
return this.roomItems.size();
|
||||
}
|
||||
|
||||
public void setHideWired(boolean hideWired) {
|
||||
this.roomInfo.setHiddenWiredEnabled(hideWired);
|
||||
|
||||
@ -3195,358 +3098,4 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.sendComposer(new ObjectsMessageComposer(this.furniOwnerNames, this.roomSpecialTypes.getExtras()).compose());
|
||||
}
|
||||
}
|
||||
|
||||
public FurnitureMovementError canPlaceFurnitureAt(RoomItem item, Habbo habbo, RoomTile tile, int rotation) {
|
||||
if (this.itemCount() >= Room.MAXIMUM_FURNI) {
|
||||
return FurnitureMovementError.MAX_ITEMS;
|
||||
}
|
||||
|
||||
if (item instanceof InteractionMoodLight && !this.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class).isEmpty()) {
|
||||
return FurnitureMovementError.MAX_DIMMERS;
|
||||
}
|
||||
if (item instanceof InteractionJukeBox && !this.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) {
|
||||
return FurnitureMovementError.MAX_SOUNDFURNI;
|
||||
}
|
||||
|
||||
if (tile == null || tile.getState() == RoomTileState.INVALID) {
|
||||
return FurnitureMovementError.INVALID_MOVE;
|
||||
}
|
||||
|
||||
rotation %= 8;
|
||||
if (this.hasRights(habbo) || this.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS) || habbo.hasRight(Permission.ACC_MOVEROTATE)) {
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
if (habbo.getHabboStats().isRentingSpace()) {
|
||||
RoomItem rentSpace = this.getHabboItem(habbo.getHabboStats().getRentedItemId());
|
||||
|
||||
if (rentSpace != null) {
|
||||
if (!RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(tile.getX(), tile.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))) {
|
||||
return FurnitureMovementError.NO_RIGHTS;
|
||||
} else {
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (RoomItem area : this.getRoomSpecialTypes().getItemsOfType(InteractionBuildArea.class)) {
|
||||
if (((InteractionBuildArea) area).inSquare(tile) && ((InteractionBuildArea) area).isBuilder(habbo.getHabboInfo().getUsername())) {
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return FurnitureMovementError.NO_RIGHTS;
|
||||
}
|
||||
|
||||
public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation) {
|
||||
return furnitureFitsAt(tile, item, rotation, true);
|
||||
}
|
||||
|
||||
public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) {
|
||||
if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
|
||||
return FurnitureMovementError.INVALID_MOVE;
|
||||
|
||||
if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
|
||||
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
if (t.getState() == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE;
|
||||
if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) {
|
||||
if (checkForUnits) {
|
||||
if (this.roomUnitManager.hasHabbosAt(t)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||
}
|
||||
if (checkForUnits) {
|
||||
if (!this.roomUnitManager.getBotsAt(t).isEmpty()) return FurnitureMovementError.TILE_HAS_BOTS;
|
||||
}
|
||||
if (checkForUnits) {
|
||||
if (this.roomUnitManager.hasPetsAt(t)) return FurnitureMovementError.TILE_HAS_PETS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Optional<RoomItem> stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny();
|
||||
|
||||
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
|
||||
|
||||
RoomItem topItem = this.getTopItemAt(t.getX(), t.getY(), item);
|
||||
if (topItem != null && !topItem.getBaseItem().allowStack() && !t.getAllowStack()) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
||||
if ((stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) || topItem != null && (topItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() == InteractionWater.class || item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class))) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.canStackAt(tileFurniList)) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public FurnitureMovementError placeFloorFurniAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) {
|
||||
FurnitureMovementError error = this.canPlaceFurnitureAt(item, owner, tile, rotation);
|
||||
|
||||
if(!error.equals(FurnitureMovementError.NONE)) {
|
||||
return error;
|
||||
}
|
||||
|
||||
boolean pluginHelper = false;
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
|
||||
FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_PLACE;
|
||||
}
|
||||
|
||||
pluginHelper = event.hasPluginHelper();
|
||||
}
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
|
||||
FurnitureMovementError fits = this.furnitureFitsAt(tile, item, rotation);
|
||||
|
||||
if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) {
|
||||
return fits;
|
||||
}
|
||||
|
||||
double height = tile.getStackHeight();
|
||||
|
||||
for (RoomTile tile2 : occupiedTiles) {
|
||||
double sHeight = tile2.getStackHeight();
|
||||
if (sHeight > height) {
|
||||
height = sHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) {
|
||||
FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height));
|
||||
if (event.hasChangedHeight()) {
|
||||
height = event.getUpdatedHeight();
|
||||
}
|
||||
}
|
||||
|
||||
item.setZ(height);
|
||||
item.setX(tile.getX());
|
||||
item.setY(tile.getY());
|
||||
item.setRotation(rotation);
|
||||
if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) {
|
||||
this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername());
|
||||
}
|
||||
|
||||
item.needsUpdate(true);
|
||||
this.addHabboItem(item);
|
||||
item.setRoomId(this.roomInfo.getId());
|
||||
item.onPlace(this);
|
||||
this.updateTiles(occupiedTiles);
|
||||
this.sendComposer(new ObjectAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose());
|
||||
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
this.updateHabbosAt(t);
|
||||
this.updateBotsAt(t.getX(), t.getY());
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(item);
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) {
|
||||
if (!(this.hasRights(owner) || this.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) {
|
||||
return FurnitureMovementError.NO_RIGHTS;
|
||||
}
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
|
||||
Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, null);
|
||||
Emulator.getPluginManager().fireEvent(furniturePlacedEvent);
|
||||
|
||||
if (furniturePlacedEvent.isCancelled())
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_PLACE;
|
||||
}
|
||||
|
||||
item.setWallPosition(wallPosition);
|
||||
if (!this.furniOwnerNames.containsKey(item.getUserId()) && owner != null) {
|
||||
this.furniOwnerNames.put(item.getUserId(), owner.getHabboInfo().getUsername());
|
||||
}
|
||||
this.sendComposer(new ItemAddMessageComposer(item, this.getFurniOwnerName(item.getUserId())).compose());
|
||||
item.needsUpdate(true);
|
||||
this.addHabboItem(item);
|
||||
item.setRoomId(this.roomInfo.getId());
|
||||
item.onPlace(this);
|
||||
Emulator.getThreading().run(item);
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor) {
|
||||
return moveFurniTo(item, tile, rotation, actor, true, true);
|
||||
}
|
||||
|
||||
public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) {
|
||||
return moveFurniTo(item, tile, rotation, actor, sendUpdates, true);
|
||||
}
|
||||
|
||||
public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) {
|
||||
RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY());
|
||||
|
||||
boolean pluginHelper = false;
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) {
|
||||
FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile));
|
||||
if (event.isCancelled()) {
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_MOVE;
|
||||
}
|
||||
pluginHelper = event.hasPluginHelper();
|
||||
}
|
||||
|
||||
boolean magicTile = item instanceof InteractionStackHelper;
|
||||
|
||||
Optional<RoomItem> stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny();
|
||||
|
||||
//Check if can be placed at new position
|
||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
THashSet<RoomTile> newOccupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
|
||||
RoomItem topItem = this.getTopItemAt(occupiedTiles, null);
|
||||
|
||||
if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
|
||||
if (oldLocation != tile) {
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
RoomItem tileTopItem = this.getTopItemAt(t.getX(), t.getY());
|
||||
if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() ||
|
||||
(tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
||||
if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) {
|
||||
if (checkForUnits && !magicTile) {
|
||||
if (this.roomUnitManager.hasHabbosAt(t))
|
||||
return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||
if (!this.roomUnitManager.getBotsAt(t).isEmpty())
|
||||
return FurnitureMovementError.TILE_HAS_BOTS;
|
||||
if (this.roomUnitManager.hasPetsAt(t))
|
||||
return FurnitureMovementError.TILE_HAS_PETS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
|
||||
}
|
||||
|
||||
if (!magicTile && !item.canStackAt(tileFurniList)) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
THashSet<RoomTile> oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
|
||||
int oldRotation = item.getRotation();
|
||||
|
||||
if (oldRotation != rotation) {
|
||||
item.setRotation(rotation);
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) {
|
||||
Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation);
|
||||
Emulator.getPluginManager().fireEvent(furnitureRotatedEvent);
|
||||
|
||||
if (furnitureRotatedEvent.isCancelled()) {
|
||||
item.setRotation(oldRotation);
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_ROTATE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT)) {
|
||||
item.setRotation(oldRotation);
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
||||
// )
|
||||
}
|
||||
//Place at new position
|
||||
|
||||
double height;
|
||||
|
||||
if (stackHelper.isPresent()) {
|
||||
height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100);
|
||||
} else if (item == topItem) {
|
||||
height = item.getZ();
|
||||
} else {
|
||||
height = this.getStackHeight(tile.getX(), tile.getY(), false, item);
|
||||
for (RoomTile til : occupiedTiles) {
|
||||
double sHeight = this.getStackHeight(til.getX(), til.getY(), false, item);
|
||||
if (sHeight > height) {
|
||||
height = sHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK;
|
||||
if (height < this.getLayout().getHeightAtSquare(tile.getX(), tile.getY()))
|
||||
return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) {
|
||||
FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height));
|
||||
if (event.hasChangedHeight()) {
|
||||
height = event.getUpdatedHeight();
|
||||
}
|
||||
}
|
||||
|
||||
if (height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK;
|
||||
if (height < this.getLayout().getHeightAtSquare(tile.getX(), tile.getY()))
|
||||
return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor
|
||||
|
||||
item.setX(tile.getX());
|
||||
item.setY(tile.getY());
|
||||
item.setZ(height);
|
||||
if (magicTile) {
|
||||
item.setZ(tile.getZ());
|
||||
item.setExtradata("" + item.getZ() * 100);
|
||||
}
|
||||
if (item.getZ() > MAXIMUM_FURNI_HEIGHT) {
|
||||
item.setZ(MAXIMUM_FURNI_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
//Update Furniture
|
||||
item.onMove(this, oldLocation, tile);
|
||||
item.needsUpdate(true);
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
if (sendUpdates) {
|
||||
this.sendComposer(new ObjectUpdateMessageComposer(item).compose());
|
||||
}
|
||||
|
||||
//Update old & new tiles
|
||||
occupiedTiles.removeAll(oldOccupiedTiles);
|
||||
occupiedTiles.addAll(oldOccupiedTiles);
|
||||
this.updateTiles(occupiedTiles);
|
||||
|
||||
//Update Habbos at old position
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
this.updateHabbosAt(
|
||||
t.getX(),
|
||||
t.getY(),
|
||||
new ArrayList<>(this.roomUnitManager.getHabbosAt(t))
|
||||
/*.stream()
|
||||
.filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t)
|
||||
.collect(Collectors.toCollection(THashSet::new))*/
|
||||
);
|
||||
this.updateBotsAt(t.getX(), t.getY());
|
||||
}
|
||||
if (Emulator.getConfig().getBoolean("wired.place.under", false)) {
|
||||
for (RoomTile t : newOccupiedTiles) {
|
||||
for (Habbo h : this.roomUnitManager.getHabbosAt(t)) {
|
||||
try {
|
||||
item.onWalkOn(h.getRoomUnit(), this, null);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.items.ICycleable;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
|
||||
@ -20,13 +21,9 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.HeightMapUpdateMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemRemoveMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.ObjectAddMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.*;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
import com.eu.habbo.plugin.events.furniture.FurnitureBuildheightEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.FurniturePickedUpEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.FurniturePlacedEvent;
|
||||
import com.eu.habbo.plugin.events.furniture.*;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -265,6 +262,12 @@ public class RoomItemManager {
|
||||
}
|
||||
|
||||
public FurnitureMovementError placeFloorItemAt(RoomItem item, RoomTile tile, int rotation, Habbo owner) {
|
||||
FurnitureMovementError error = this.canPlaceFurnitureAt(item, owner, tile, rotation);
|
||||
|
||||
if(!error.equals(FurnitureMovementError.NONE)) {
|
||||
return error;
|
||||
}
|
||||
|
||||
boolean pluginHelper = false;
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
|
||||
FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile));
|
||||
@ -278,7 +281,7 @@ public class RoomItemManager {
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
|
||||
FurnitureMovementError fits = this.furnitureFitsAt(item, tile, rotation);
|
||||
FurnitureMovementError fits = this.furnitureFitsAt(tile, item, rotation, true);
|
||||
|
||||
if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) {
|
||||
return fits;
|
||||
@ -322,6 +325,202 @@ public class RoomItemManager {
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public FurnitureMovementError placeWallFurniAt(RoomItem item, String wallPosition, Habbo owner) {
|
||||
if (!(this.room.hasRights(owner) || this.room.getGuildRightLevel(owner).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) {
|
||||
return FurnitureMovementError.NO_RIGHTS;
|
||||
}
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
|
||||
Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, null);
|
||||
Emulator.getPluginManager().fireEvent(furniturePlacedEvent);
|
||||
|
||||
if (furniturePlacedEvent.isCancelled())
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_PLACE;
|
||||
}
|
||||
|
||||
item.setWallPosition(wallPosition);
|
||||
if (!this.room.getFurniOwnerNames().containsKey(item.getUserId()) && owner != null) {
|
||||
this.room.getFurniOwnerNames().put(item.getUserId(), owner.getHabboInfo().getUsername());
|
||||
}
|
||||
this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getUserId())).compose());
|
||||
item.needsUpdate(true);
|
||||
this.addRoomItem(item);
|
||||
item.setRoomId(this.room.getRoomInfo().getId());
|
||||
item.onPlace(this.room);
|
||||
Emulator.getThreading().run(item);
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor) {
|
||||
return moveFurniTo(item, tile, rotation, actor, true, true);
|
||||
}
|
||||
|
||||
public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) {
|
||||
return moveFurniTo(item, tile, rotation, actor, sendUpdates, true);
|
||||
}
|
||||
|
||||
public FurnitureMovementError moveFurniTo(RoomItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) {
|
||||
RoomTile oldLocation = this.room.getLayout().getTile(item.getX(), item.getY());
|
||||
|
||||
boolean pluginHelper = false;
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) {
|
||||
FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile));
|
||||
if (event.isCancelled()) {
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_MOVE;
|
||||
}
|
||||
pluginHelper = event.hasPluginHelper();
|
||||
}
|
||||
|
||||
boolean magicTile = item instanceof InteractionStackHelper;
|
||||
|
||||
Optional<RoomItem> stackHelper = this.room.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny();
|
||||
|
||||
//Check if can be placed at new position
|
||||
THashSet<RoomTile> occupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
THashSet<RoomTile> newOccupiedTiles = this.room.getLayout().getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
|
||||
RoomItem topItem = this.room.getTopItemAt(occupiedTiles, null);
|
||||
|
||||
if ((stackHelper.isEmpty() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
|
||||
if (oldLocation != tile) {
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
RoomItem tileTopItem = this.room.getTopItemAt(t.getX(), t.getY());
|
||||
if (!magicTile && (tileTopItem != null && tileTopItem != item ? (t.getState().equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() ||
|
||||
(tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.room.calculateTileState(t, item).equals(RoomTileState.INVALID)) || stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
||||
if (!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) {
|
||||
if (checkForUnits && !magicTile) {
|
||||
if (this.room.getRoomUnitManager().hasHabbosAt(t))
|
||||
return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||
if (!this.room.getRoomUnitManager().getBotsAt(t).isEmpty())
|
||||
return FurnitureMovementError.TILE_HAS_BOTS;
|
||||
if (this.room.getRoomUnitManager().hasPetsAt(t))
|
||||
return FurnitureMovementError.TILE_HAS_PETS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<RoomTile, THashSet<RoomItem>>> tileFurniList = new ArrayList<>();
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
tileFurniList.add(Pair.create(t, this.room.getItemsAt(t)));
|
||||
}
|
||||
|
||||
if (!magicTile && !item.canStackAt(tileFurniList)) {
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
}
|
||||
|
||||
THashSet<RoomTile> oldOccupiedTiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
|
||||
|
||||
int oldRotation = item.getRotation();
|
||||
|
||||
if (oldRotation != rotation) {
|
||||
item.setRotation(rotation);
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) {
|
||||
Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation);
|
||||
Emulator.getPluginManager().fireEvent(furnitureRotatedEvent);
|
||||
|
||||
if (furnitureRotatedEvent.isCancelled()) {
|
||||
item.setRotation(oldRotation);
|
||||
return FurnitureMovementError.CANCEL_PLUGIN_ROTATE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > Room.MAXIMUM_FURNI_HEIGHT)) {
|
||||
item.setRotation(oldRotation);
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
||||
// )
|
||||
}
|
||||
//Place at new position
|
||||
|
||||
double height;
|
||||
|
||||
if (stackHelper.isPresent()) {
|
||||
height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100);
|
||||
} else if (item == topItem) {
|
||||
height = item.getZ();
|
||||
} else {
|
||||
height = this.room.getStackHeight(tile.getX(), tile.getY(), false, item);
|
||||
for (RoomTile til : occupiedTiles) {
|
||||
double sHeight = this.room.getStackHeight(til.getX(), til.getY(), false, item);
|
||||
if (sHeight > height) {
|
||||
height = sHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (height > Room.MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK;
|
||||
if (height < this.room.getLayout().getHeightAtSquare(tile.getX(), tile.getY()))
|
||||
return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) {
|
||||
FurnitureBuildheightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height));
|
||||
if (event.hasChangedHeight()) {
|
||||
height = event.getUpdatedHeight();
|
||||
}
|
||||
}
|
||||
|
||||
if (height > Room.MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK;
|
||||
if (height < this.room.getLayout().getHeightAtSquare(tile.getX(), tile.getY()))
|
||||
return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor
|
||||
|
||||
item.setX(tile.getX());
|
||||
item.setY(tile.getY());
|
||||
item.setZ(height);
|
||||
if (magicTile) {
|
||||
item.setZ(tile.getZ());
|
||||
item.setExtradata("" + item.getZ() * 100);
|
||||
}
|
||||
if (item.getZ() > Room.MAXIMUM_FURNI_HEIGHT) {
|
||||
item.setZ(Room.MAXIMUM_FURNI_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
//Update Furniture
|
||||
item.onMove(this.room, oldLocation, tile);
|
||||
item.needsUpdate(true);
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
if (sendUpdates) {
|
||||
this.room.sendComposer(new ObjectUpdateMessageComposer(item).compose());
|
||||
}
|
||||
|
||||
//Update old & new tiles
|
||||
occupiedTiles.removeAll(oldOccupiedTiles);
|
||||
occupiedTiles.addAll(oldOccupiedTiles);
|
||||
this.room.updateTiles(occupiedTiles);
|
||||
|
||||
//Update Habbos at old position
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
this.room.updateHabbosAt(
|
||||
t.getX(),
|
||||
t.getY(),
|
||||
new ArrayList<>(this.room.getRoomUnitManager().getHabbosAt(t))
|
||||
/*.stream()
|
||||
.filter(h -> !h.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || h.getRoomUnit().getGoal() == t)
|
||||
.collect(Collectors.toCollection(THashSet::new))*/
|
||||
);
|
||||
this.room.updateBotsAt(t.getX(), t.getY());
|
||||
}
|
||||
if (Emulator.getConfig().getBoolean("wired.place.under", false)) {
|
||||
for (RoomTile t : newOccupiedTiles) {
|
||||
for (Habbo h : this.room.getRoomUnitManager().getHabbosAt(t)) {
|
||||
try {
|
||||
item.onWalkOn(h.getRoomUnit(), this.room, null);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FurnitureMovementError.NONE;
|
||||
}
|
||||
|
||||
public void pickUpItem(RoomItem item, Habbo picker) {
|
||||
if (item == null)
|
||||
return;
|
||||
@ -375,11 +574,7 @@ public class RoomItemManager {
|
||||
Emulator.getThreading().run(item);
|
||||
}
|
||||
|
||||
public FurnitureMovementError furnitureFitsAt(RoomItem item, RoomTile tile, int rotation) {
|
||||
return furnitureFitsAt(item, tile, rotation, true);
|
||||
}
|
||||
|
||||
public FurnitureMovementError furnitureFitsAt(RoomItem item, RoomTile tile, int rotation, boolean checkForUnits) {
|
||||
public FurnitureMovementError furnitureFitsAt(RoomTile tile, RoomItem item, int rotation, boolean checkForUnits) {
|
||||
if (!this.room.getLayout().fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
|
||||
return FurnitureMovementError.INVALID_MOVE;
|
||||
|
||||
|
@ -712,7 +712,7 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
int effect = habbo.getInventory().getEffectsComponent().getActivatedEffect();
|
||||
room.giveEffect(habbo.getRoomUnit(), effect, -1);
|
||||
habbo.getRoomUnit().giveEffect(effect, -1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +85,9 @@ public class RoomUnitManager {
|
||||
bot.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
|
||||
bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
|
||||
bot.getRoomUnit().setInRoom(true);
|
||||
this.room.giveEffect(bot.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE);
|
||||
|
||||
bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false);
|
||||
|
||||
this.addRoomUnit(bot);
|
||||
}
|
||||
}
|
||||
|
@ -349,22 +349,22 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
|
||||
|
||||
for (Habbo habbo : room.getHabbosOnItem(this)) {
|
||||
if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, nextEffectM, -1);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectM, -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, nextEffectF, -1);
|
||||
habbo.getRoomUnit().giveEffect(nextEffectF, -1);
|
||||
}
|
||||
}
|
||||
|
||||
RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
|
||||
for (Bot bot : room.getRoomUnitManager().getBotsAt(tile)) {
|
||||
if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(bot.getRoomUnit(), nextEffectM, -1);
|
||||
bot.getRoomUnit().giveEffect(nextEffectM, -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(bot.getRoomUnit(), nextEffectF, -1);
|
||||
bot.getRoomUnit().giveEffect(nextEffectF, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -404,39 +404,39 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
|
||||
|
||||
oldHabbos.forEach(habbo -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, finalNextEffectM, -1);
|
||||
habbo.getRoomUnit().giveEffect(finalNextEffectM, -1);
|
||||
}
|
||||
if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, finalNextEffectF, -1);
|
||||
habbo.getRoomUnit().giveEffect(finalNextEffectF, -1);
|
||||
}
|
||||
});
|
||||
|
||||
newHabbos.forEach(habbo -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
}
|
||||
if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
habbo.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
oldBots.forEach(bot -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(bot.getRoomUnit(), finalNextEffectM, -1);
|
||||
bot.getRoomUnit().giveEffect(finalNextEffectM, -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(bot.getRoomUnit(), finalNextEffectF, -1);
|
||||
bot.getRoomUnit().giveEffect(finalNextEffectF, -1);
|
||||
}
|
||||
});
|
||||
|
||||
newBots.forEach(bot -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1);
|
||||
bot.getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1);
|
||||
}
|
||||
if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1);
|
||||
bot.getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.users.DanceType;
|
||||
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.outgoing.rooms.users.AvatarEffectMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
||||
import com.eu.habbo.plugin.Event;
|
||||
@ -298,6 +299,37 @@ public class RoomAvatar extends RoomUnit {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void giveEffect(int effectId, int duration) {
|
||||
this.giveEffect(effectId, duration, false);
|
||||
}
|
||||
|
||||
public void giveEffect(int effectId, int duration, boolean forceEffect) {
|
||||
if (!this.isInRoom()) {
|
||||
return;
|
||||
} else {
|
||||
RoomAvatar roomAvatar = this;
|
||||
}
|
||||
|
||||
if(this instanceof RoomHabbo) {
|
||||
Habbo habbo = this.getRoom().getRoomUnitManager().getHabboByRoomUnit(this);
|
||||
if(habbo == null || (habbo.getHabboInfo().isInGame() && !forceEffect)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (duration == -1 || duration == Integer.MAX_VALUE) {
|
||||
duration = Integer.MAX_VALUE;
|
||||
} else {
|
||||
duration += Emulator.getIntUnixTimestamp();
|
||||
}
|
||||
|
||||
if ((this.getRoom().isAllowEffects() || forceEffect) && !this.isSwimming()) {
|
||||
this.setEffectId(effectId);
|
||||
this.setEffectEndTimestamp(duration);
|
||||
this.getRoom().sendComposer(new AvatarEffectMessageComposer(this).compose());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSitStatus(RoomItem topItem) {
|
||||
if(!this.isCmdSitEnabled()) {
|
||||
if((topItem == null || !topItem.getBaseItem().allowSit()) && this.hasStatus(RoomUnitStatus.SIT)) {
|
||||
|
@ -290,8 +290,7 @@ public class HabboInfo implements Runnable {
|
||||
riding.setTask(PetTasks.FREE);
|
||||
this.setRiding(null);
|
||||
|
||||
if (room != null)
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
habbo.getRoomUnit().giveEffect(0, -1);
|
||||
|
||||
RoomUnit roomUnit = habbo.getRoomUnit();
|
||||
if (roomUnit == null)
|
||||
@ -300,8 +299,8 @@ public class HabboInfo implements Runnable {
|
||||
roomUnit.setCurrentZ(riding.getRoomUnit().getCurrentZ());
|
||||
roomUnit.setPreviousLocationZ(riding.getRoomUnit().getCurrentZ());
|
||||
roomUnit.stopWalking();
|
||||
if (room != null)
|
||||
room.sendComposer(new UserUpdateComposer(roomUnit).compose());
|
||||
|
||||
room.sendComposer(new UserUpdateComposer(roomUnit).compose());
|
||||
|
||||
List<RoomTile> availableTiles = isRemoving ? new ArrayList<>() : room.getLayout().getWalkableTilesAround(roomUnit.getCurrentPosition());
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class EffectsComponent {
|
||||
this.activatedEffect = effectId;
|
||||
|
||||
if (this.habbo.getRoomUnit().getRoom() != null) {
|
||||
this.habbo.getRoomUnit().getRoom().giveEffect(this.habbo, effectId, effect.remainingTime());
|
||||
this.habbo.getRoomUnit().giveEffect(effectId, effect.remainingTime());
|
||||
}
|
||||
|
||||
this.habbo.getClient().sendResponse(new AvatarEffectActivatedMessageComposer(effect));
|
||||
|
@ -26,14 +26,14 @@ public class MoveObjectEvent extends MessageHandler {
|
||||
int rotation = this.packet.readInt();
|
||||
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
|
||||
|
||||
FurnitureMovementError error = room.canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation);
|
||||
FurnitureMovementError error = room.getRoomItemManager().canPlaceFurnitureAt(item, this.client.getHabbo(), tile, rotation);
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode()));
|
||||
this.client.sendResponse(new ObjectUpdateMessageComposer(item));
|
||||
return;
|
||||
}
|
||||
|
||||
error = room.moveFurniTo(item, tile, rotation, this.client.getHabbo());
|
||||
error = room.getRoomItemManager().moveFurniTo(item, tile, rotation, this.client.getHabbo());
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode()));
|
||||
this.client.sendResponse(new ObjectUpdateMessageComposer(item));
|
||||
|
@ -26,7 +26,7 @@ public class PickupObjectEvent extends MessageHandler {
|
||||
return;
|
||||
|
||||
if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) {
|
||||
room.pickUpItem(item, this.client.getHabbo());
|
||||
room.getRoomItemManager().pickUpItem(item, this.client.getHabbo());
|
||||
} else {
|
||||
if (room.hasRights(this.client.getHabbo())) {
|
||||
if (this.client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) {
|
||||
|
@ -93,7 +93,7 @@ public class PlaceObjectEvent extends MessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
FurnitureMovementError error = room.placeFloorFurniAt(item, tile, rotation, this.client.getHabbo());
|
||||
FurnitureMovementError error = room.getRoomItemManager().placeFloorItemAt(item, tile, rotation, this.client.getHabbo());
|
||||
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode()));
|
||||
@ -101,7 +101,7 @@ public class PlaceObjectEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
} else {
|
||||
FurnitureMovementError error = room.placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo());
|
||||
FurnitureMovementError error = room.getRoomItemManager().placeWallFurniAt(item, values[1] + " " + values[2] + " " + values[3], this.client.getHabbo());
|
||||
if (!error.equals(FurnitureMovementError.NONE)) {
|
||||
this.client.sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), error.getErrorCode()));
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@ public class AvatarEffectSelectedEvent extends MessageHandler {
|
||||
this.client.getHabbo().getInventory().getEffectsComponent().setActivatedEffect(0);
|
||||
|
||||
if (this.client.getHabbo().getRoomUnit().getRoom() != null) {
|
||||
this.client.getHabbo().getRoomUnit().getRoom().giveEffect(this.client.getHabbo().getRoomUnit(), 0, -1);
|
||||
this.client.getHabbo().getRoomUnit().giveEffect(0, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,18 +75,19 @@ public class ApplySnapshotEvent extends MessageHandler {
|
||||
|
||||
// Match Position & Rotation
|
||||
if (wired.shouldMatchRotation() && !wired.shouldMatchPosition()) {
|
||||
if (matchItem.getRotation() != setting.getRotation() && room.furnitureFitsAt(oldLocation, matchItem, setting.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
room.moveFurniTo(matchItem, oldLocation, setting.getRotation(), null, true);
|
||||
if (matchItem.getRotation() != setting.getRotation() && room.getRoomItemManager().furnitureFitsAt(oldLocation, matchItem, setting.getRotation(), false) == FurnitureMovementError.NONE) {
|
||||
room.getRoomItemManager().moveFurniTo(matchItem, oldLocation, setting.getRotation(), null, true, true);
|
||||
}
|
||||
} else if (wired.shouldMatchPosition()) {
|
||||
boolean slideAnimation = !wired.shouldMatchRotation() || matchItem.getRotation() == setting.getRotation();
|
||||
RoomTile newLocation = room.getLayout().getTile((short) setting.getX(), (short) setting.getY());
|
||||
int newRotation = wired.shouldMatchRotation() ? setting.getRotation() : matchItem.getRotation();
|
||||
|
||||
if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation())
|
||||
&& room.furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE
|
||||
&& room.moveFurniTo(matchItem, newLocation, newRotation, null, !slideAnimation) == FurnitureMovementError.NONE && slideAnimation) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose());
|
||||
if (newLocation != null && newLocation.getState() != RoomTileState.INVALID && (newLocation != oldLocation || newRotation != matchItem.getRotation()) && room.getRoomItemManager().furnitureFitsAt(newLocation, matchItem, newRotation, true) == FurnitureMovementError.NONE) {
|
||||
boolean sendUpdates = !slideAnimation;
|
||||
if (room.getRoomItemManager().moveFurniTo(matchItem, newLocation, newRotation, null, sendUpdates, true) == FurnitureMovementError.NONE && slideAnimation) {
|
||||
room.sendComposer(new FloorItemOnRollerComposer(matchItem, null, oldLocation, oldZ, newLocation, matchItem.getZ(), 0, room).compose());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ public class RoomUnitRidePet implements Runnable {
|
||||
|
||||
if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) {
|
||||
habbo.getRoomUnit().stopWalking();
|
||||
habbo.getRoomUnit().getRoom().giveEffect(habbo, 77, -1);
|
||||
habbo.getRoomUnit().giveEffect(77, -1);
|
||||
habbo.getHabboInfo().setRiding(pet);
|
||||
habbo.getRoomUnit().setCurrentPosition(this.pet.getRoomUnit().getCurrentPosition());
|
||||
habbo.getRoomUnit().setPreviousLocation(this.pet.getRoomUnit().getCurrentPosition());
|
||||
|
@ -81,7 +81,7 @@ public class YouAreAPirate implements Runnable {
|
||||
this.habbo = habbo;
|
||||
this.room = room;
|
||||
this.oldEffect = this.habbo.getRoomUnit().getEffectId();
|
||||
this.room.giveEffect(this.habbo, 161, -1);
|
||||
this.habbo.getRoomUnit().giveEffect(161, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,7 +93,7 @@ public class YouAreAPirate implements Runnable {
|
||||
this.index++;
|
||||
|
||||
if (this.index == iamapirate.length) {
|
||||
this.room.giveEffect(this.habbo, this.oldEffect, -1);
|
||||
this.habbo.getRoomUnit().giveEffect(this.oldEffect, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user