2018-09-28 21:25:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.items.interactions;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.items.Item;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.Room;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
2018-11-17 14:28:00 +01:00
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import com.eu.habbo.habbohotel.users.HabboGender;
|
2018-09-28 21:25:00 +02:00
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class InteractionTrap extends InteractionDefault {
|
|
|
|
public InteractionTrap(ResultSet set, Item baseItem) throws SQLException {
|
2018-09-28 21:25:00 +02:00
|
|
|
super(set, baseItem);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public InteractionTrap(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
2018-09-28 21:25:00 +02:00
|
|
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
2018-09-28 21:25:00 +02:00
|
|
|
super.onWalkOn(roomUnit, room, objects);
|
|
|
|
|
2018-11-17 14:28:00 +01:00
|
|
|
if (!this.getExtradata().equals("1"))
|
|
|
|
return;
|
|
|
|
|
2018-09-28 21:25:00 +02:00
|
|
|
int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName());
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (delay == 0) {
|
2018-09-28 21:25:00 +02:00
|
|
|
Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000");
|
|
|
|
delay = 3000;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (roomUnit != null) {
|
|
|
|
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
|
|
|
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
|
2018-11-17 14:28:00 +01:00
|
|
|
Habbo habbo = room.getHabbo(roomUnit);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
|
|
|
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
2019-03-18 02:22:00 +01:00
|
|
|
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
2018-11-17 14:28:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
2019-03-18 02:22:00 +01:00
|
|
|
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
2018-11-17 14:28:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
roomUnit.setCanWalk(false);
|
2020-04-23 19:08:37 +02:00
|
|
|
Emulator.getThreading().run(() -> {
|
|
|
|
room.giveEffect(roomUnit, 0, -1);
|
|
|
|
roomUnit.setCanWalk(true);
|
2018-11-17 14:28:00 +01:00
|
|
|
}, delay);
|
|
|
|
}
|
|
|
|
}
|
2018-09-28 21:25:00 +02:00
|
|
|
}
|
2018-11-17 14:28:00 +01:00
|
|
|
}
|
2018-09-28 21:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
2018-09-28 21:25:00 +02:00
|
|
|
}
|
|
|
|
}
|