diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 27f8c25e..18cfbee0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4451,7 +4451,16 @@ public class Room implements Comparable, ISerialize, Runnable { return fits; } - item.setZ(tile.getStackHeight()); + double height = tile.getStackHeight(); + + if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { + FurnitureBuildheightEvent event = (FurnitureBuildheightEvent) Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height)); + if (event.hasChangedHeight()) { + height = event.getUpdatedHeight(); + } + } + + item.setZ(height); item.setX(tile.x); item.setY(tile.y); item.setRotation(rotation); @@ -4567,6 +4576,13 @@ public class Room implements Comparable, ISerialize, Runnable { height = this.getStackHeight(tile.x, tile.y, false, item); } + if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) { + FurnitureBuildheightEvent event = (FurnitureBuildheightEvent) Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, actor, 0.00, height)); + if (event.hasChangedHeight()) { + height = event.getUpdatedHeight(); + } + } + if(height > 40d) return FurnitureMovementError.CANT_STACK; item.setX(tile.x); diff --git a/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java new file mode 100644 index 00000000..ada589e7 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureBuildheightEvent.java @@ -0,0 +1,30 @@ +package com.eu.habbo.plugin.events.furniture; + +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboItem; + +public class FurnitureBuildheightEvent extends FurnitureUserEvent { + + public final double oldHeight; + public final double newHeight; + + private double updatedHeight; + + private boolean changedHeight = false; + + public FurnitureBuildheightEvent(HabboItem furniture, Habbo habbo, double oldHeight, double newHeight) { + super(furniture, habbo); + + this.oldHeight = oldHeight; + this.newHeight = newHeight; + } + + public void setNewHeight(double updatedHeight) { + this.updatedHeight = updatedHeight; + this.changedHeight = true; + } + + public boolean hasChangedHeight() { return changedHeight; } + + public double getUpdatedHeight() { return updatedHeight; } +}