Fix InteractionGymEquipment

This commit is contained in:
brenoepic 2022-12-03 16:18:47 -03:00
parent b97aeca766
commit 9d54879dd3
2 changed files with 35 additions and 6 deletions

View File

@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -55,13 +57,40 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
@Override @Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects); super.onWalkOff(roomUnit, room, objects);
room.giveEffect(roomUnit, 0, -1);
if (this.forceRotation()) { if (room == null) return;
roomUnit.canRotate = true;
}
this.reset(room); this.reset(room);
if (roomUnit != null) {
Habbo habbo = room.getHabbo(roomUnit);
HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().x, roomUnit.getCurrentLocation().y);
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
} else if (roomUnit.getPreviousEffectId() > 0) {
nextEffectF = roomUnit.getPreviousEffectId();
nextEffectM = roomUnit.getPreviousEffectId();
nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
}
if (this.forceRotation()) {
roomUnit.canRotate = true;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
}
}
} }
public String achievementName() { public String achievementName() {

View File

@ -4162,12 +4162,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void giveEffect(Habbo habbo, int effectId, int duration, boolean ignoreChecks) { public void giveEffect(Habbo habbo, int effectId, int duration, boolean ignoreChecks) {
if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
this.giveEffect(habbo.getRoomUnit(), effectId, duration, ignoreChecks); this.giveEffect(habbo.getRoomUnit(), effectId, duration, ignoreChecks);
} }
} }
public void giveEffect(Habbo habbo, int effectId, int duration) { public void giveEffect(Habbo habbo, int effectId, int duration) {
if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) {
this.giveEffect(habbo.getRoomUnit(), effectId, duration, false); this.giveEffect(habbo.getRoomUnit(), effectId, duration, false);
} }
} }