Fixed unnecessary spam of RoomUserDanceComposer packets

This commit is contained in:
Beny 2020-10-15 04:56:48 +02:00
parent 9b25c37525
commit f8d0893c13
2 changed files with 10 additions and 8 deletions

View File

@ -4272,14 +4272,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public void dance(RoomUnit unit, DanceType danceType) {
boolean isDancing = !unit.getDanceType().equals(DanceType.NONE);
unit.setDanceType(danceType);
this.sendComposer(new RoomUserDanceComposer(unit).compose());
if(unit.getDanceType() != danceType) {
boolean isDancing = !unit.getDanceType().equals(DanceType.NONE);
unit.setDanceType(danceType);
this.sendComposer(new RoomUserDanceComposer(unit).compose());
if (danceType.equals(DanceType.NONE) && isDancing) {
WiredHandler.handle(WiredTriggerType.STOPS_DANCING, unit, this, new Object[]{unit});
} else if (!danceType.equals(DanceType.NONE) && !isDancing) {
WiredHandler.handle(WiredTriggerType.STARTS_DANCING, unit, this, new Object[]{unit});
if (danceType.equals(DanceType.NONE) && isDancing) {
WiredHandler.handle(WiredTriggerType.STOPS_DANCING, unit, this, new Object[]{unit});
} else if (!danceType.equals(DanceType.NONE) && !isDancing) {
WiredHandler.handle(WiredTriggerType.STARTS_DANCING, unit, this, new Object[]{unit});
}
}
}

View File

@ -308,7 +308,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, roomUnit, room, new Object[]{this});
if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && roomUnit.getDanceType() != DanceType.NONE) {
if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && !roomUnit.getDanceType().equals(DanceType.NONE)) {
roomUnit.setDanceType(DanceType.NONE);
room.sendComposer(new RoomUserDanceComposer(roomUnit).compose());
}