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

88 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.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
2018-12-22 11:39:00 +01:00
import com.eu.habbo.habbohotel.rooms.RoomTile;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
2018-12-22 11:39:00 +01:00
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
2018-07-06 15:30:00 +02:00
import java.sql.ResultSet;
import java.sql.SQLException;
2018-12-22 11:39:00 +01:00
import java.util.List;
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public class InteractionRoller extends HabboItem {
2019-04-22 01:42:00 +02:00
public static boolean NO_RULES = false;
public static int DELAY = 400;
2019-05-26 20:14:53 +02:00
public InteractionRoller(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 InteractionRoller(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-05-26 20:14:53 +02:00
public void serializeExtradata(ServerMessage serverMessage) {
2018-07-06 15:30:00 +02:00
serverMessage.appendInt((this.isLimited() ? 256 : 0));
serverMessage.appendString(this.getExtradata());
super.serializeExtradata(serverMessage);
}
@Override
2019-05-26 20:14:53 +02:00
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
2018-07-06 15:30:00 +02:00
return true;
}
@Override
2019-05-26 20:14:53 +02:00
public boolean isWalkable() {
2018-07-06 15:30:00 +02:00
return true;
}
@Override
2019-05-26 20:14:53 +02:00
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
super.onClick(client, room, objects);
}
@Override
2019-05-26 20:14:53 +02:00
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
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);
}
@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);
}
2018-12-22 11:39:00 +01:00
@Override
2019-05-26 20:14:53 +02:00
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation) {
2019-04-22 01:42:00 +02:00
if (NO_RULES) return true;
2018-12-22 11:39:00 +01:00
if (itemsAtLocation.isEmpty()) return false;
2019-05-26 20:14:53 +02:00
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation) {
if (set.getValue() != null && !set.getValue().isEmpty()) {
if (set.getValue().size() > 1) {
2018-12-22 11:39:00 +01:00
return false;
2019-05-26 20:14:53 +02:00
} else if (!set.getValue().contains(this)) {
2018-12-22 11:39:00 +01:00
return false;
}
}
}
return true;
}
2018-07-06 15:30:00 +02:00
}