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

75 lines
2.2 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;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
2019-05-26 20:14:53 +02:00
public class InteractionJukeBox extends HabboItem {
public InteractionJukeBox(ResultSet set, Item baseItem) throws SQLException {
2018-07-06 15:30:00 +02:00
super(set, baseItem);
}
2019-05-26 20:14:53 +02:00
public InteractionJukeBox(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);
}
@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 false;
}
@Override
2019-05-26 20:14:53 +02:00
public boolean isWalkable() {
2018-07-06 15:30:00 +02:00
return false;
}
@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 onClick(GameClient client, Room room, Object[] objects) throws Exception {
2018-07-06 15:30:00 +02:00
super.onClick(client, room, objects);
2019-05-26 20:14:53 +02:00
if (client != null && objects.length == 1) {
if ((Integer) objects[0] == 0) {
if (room.getTraxManager().isPlaying()) {
2018-07-06 15:30:00 +02:00
room.getTraxManager().stop();
2019-05-26 20:14:53 +02:00
} else {
2019-05-26 19:00:47 +02:00
room.getTraxManager().play(0, client.getHabbo());
2018-07-06 15:30:00 +02:00
}
}
}
}
@Override
2019-05-26 20:14:53 +02:00
public void onPickUp(Room room) {
2018-07-06 15:30:00 +02:00
super.onPickUp(room);
this.setExtradata("0");
2020-07-02 22:44:13 +02:00
room.getTraxManager().removeTraxOnRoom(this);
2018-07-06 15:30:00 +02:00
}
@Override
2019-05-26 20:14:53 +02:00
public void onPlace(Room room) {
2018-07-06 15:30:00 +02:00
super.onPlace(room);
2020-07-02 22:44:13 +02:00
room.getTraxManager().addTraxOnRoom(this);
2019-05-26 20:14:53 +02:00
if (room.getTraxManager().isPlaying()) {
2018-07-06 15:30:00 +02:00
this.setExtradata("1");
}
}
}