Merge branch 'buildheight_plugin_event' into 'dev'

Buildheight Plugin Event

See merge request morningstar/Arcturus-Community!239
This commit is contained in:
Harmonic 2020-07-06 12:05:33 -04:00
commit 5038b02445
2 changed files with 47 additions and 1 deletions

View File

@ -4451,7 +4451,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return fits; 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.setX(tile.x);
item.setY(tile.y); item.setY(tile.y);
item.setRotation(rotation); item.setRotation(rotation);
@ -4567,6 +4576,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
height = this.getStackHeight(tile.x, tile.y, false, item); 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; if(height > 40d) return FurnitureMovementError.CANT_STACK;
item.setX(tile.x); 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; }
}