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

77 lines
2.6 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer;
import com.eu.habbo.threading.runnables.CloseGate;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionHabboClubGate extends InteractionDefault implements ConditionalGate {
2019-05-26 20:14:53 +02:00
public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException {
2018-07-06 15:30:00 +02:00
super(set, baseItem);
this.setExtradata("0");
2018-07-06 15:30:00 +02:00
}
2019-05-26 20:14:53 +02:00
public InteractionHabboClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
2018-07-06 15:30:00 +02:00
super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0");
2018-07-06 15:30:00 +02:00
}
@Override
2019-08-04 16:23:04 +02:00
public boolean isWalkable() {
return true;
2018-07-06 15:30:00 +02:00
}
@Override
2019-08-04 16:23:04 +02:00
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
Habbo habbo = room.getHabbo(roomUnit);
return habbo != null && habbo.getHabboStats().hasActiveClub();
2018-07-06 15:30:00 +02:00
}
@Override
2019-05-26 20:14:53 +02:00
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
super.onWalkOn(roomUnit, room, objects);
2019-05-26 20:14:53 +02:00
if (this.canWalkOn(roomUnit, room, objects)) {
2018-07-06 15:30:00 +02:00
this.setExtradata("1");
room.updateItemState(this);
}
}
@Override
2019-05-26 20:14:53 +02:00
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
if (client != null) {
if (this.canWalkOn(client.getHabbo().getRoomUnit(), room, null)) {
2019-03-18 02:22:00 +01:00
super.onClick(client, room, objects);
2019-05-26 20:14:53 +02:00
} else {
2019-03-18 02:22:00 +01:00
client.sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
}
2018-07-06 15:30:00 +02:00
}
}
2019-05-26 20:14:53 +02:00
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
super.onWalkOff(roomUnit, room, objects);
2019-08-04 16:23:04 +02:00
Emulator.getThreading().run(new CloseGate(this, room), 1000);
2018-07-06 15:30:00 +02:00
}
@Override
public void onRejected(RoomUnit roomUnit, Room room, Object[] objects) {
if (roomUnit == null || room == null)
return;
room.getHabbo(roomUnit).getClient().sendResponse(
new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC)
);
}
2018-07-06 15:30:00 +02:00
}