Buildheight Plugin Event

This commit is contained in:
ArpyAge 2020-06-08 17:38:22 +02:00
parent 62ab54a3e3
commit 8876f07147
2 changed files with 47 additions and 1 deletions

View File

@ -4446,7 +4446,16 @@ public class Room implements Comparable<Room>, 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);
@ -4562,6 +4571,13 @@ public class Room implements Comparable<Room>, 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);

View File

@ -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; }
}