Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java

86 lines
3.0 KiB
Java
Raw Normal View History

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;
2018-11-17 14:28:00 +01:00
public class InteractionTrap extends InteractionDefault
2018-09-28 21:25:00 +02:00
{
public InteractionTrap(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionTrap(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
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());
if (delay == 0)
{
Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000");
delay = 3000;
}
2018-11-17 14:28:00 +01:00
if (roomUnit != null)
2018-09-28 21:25:00 +02:00
{
2018-11-17 14:28:00 +01:00
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
2018-09-28 21:25:00 +02:00
{
2018-11-17 14:28:00 +01:00
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER))
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
{
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM())
{
room.giveEffect(habbo, this.getBaseItem().getEffectM());
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF())
{
room.giveEffect(habbo, this.getBaseItem().getEffectF());
return;
}
roomUnit.setCanWalk(false);
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
room.giveEffect(roomUnit, 0);
roomUnit.setCanWalk(true);
}
}, 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
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
}
}