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

88 lines
2.5 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.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;
2020-05-04 22:24:09 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2018-07-06 15:30:00 +02:00
import java.sql.ResultSet;
import java.sql.SQLException;
2019-05-26 20:14:53 +02:00
public class InteractionMusicDisc extends HabboItem {
2020-05-04 22:24:09 +02:00
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionMusicDisc.class);
2018-07-06 15:30:00 +02:00
private int songId;
2019-05-26 20:14:53 +02:00
public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException {
2018-07-06 15:30:00 +02:00
super(set, baseItem);
String[] stuff = this.getExtradata().split("\n");
2019-05-26 20:14:53 +02:00
if (stuff.length >= 7 && !stuff[6].isEmpty()) {
try {
2019-04-22 01:42:00 +02:00
this.songId = Integer.valueOf(stuff[6]);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2020-05-04 22:24:09 +02:00
LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
2019-04-22 01:42:00 +02:00
}
2018-07-06 15:30:00 +02:00
}
}
2019-05-26 20:14:53 +02:00
public InteractionMusicDisc(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);
String[] stuff = this.getExtradata().split("\n");
2019-05-26 20:14:53 +02:00
if (stuff.length >= 7 && !stuff[6].isEmpty()) {
try {
2019-04-22 01:42:00 +02:00
this.songId = Integer.valueOf(stuff[6]);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2020-05-04 22:24:09 +02:00
LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
2019-04-22 01:42:00 +02:00
}
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 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
}
2019-05-26 20:14:53 +02:00
public int getSongId() {
2019-03-18 02:22:00 +01:00
return this.songId;
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-02-01 13:09:59 +01:00
room.getTraxManager().sendUpdatedSongList();
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);
2020-02-01 13:09:59 +01:00
room.getTraxManager().sendUpdatedSongList();
2018-07-06 15:30:00 +02:00
}
}