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

95 lines
2.7 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.items.interactions;
2019-04-22 01:42:00 +02:00
import com.eu.habbo.Emulator;
2018-07-06 15:30:00 +02:00
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 com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
2019-05-26 20:14:53 +02:00
public class InteractionMusicDisc extends HabboItem {
2018-07-06 15:30:00 +02:00
private int songId;
private boolean inQueue;
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) {
2019-04-22 01:42:00 +02:00
Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
}
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) {
2019-04-22 01:42:00 +02:00
Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
}
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);
room.sendComposer(new JukeBoxMySongsComposer(room.getTraxManager().myList()).compose());
}
@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);
room.getTraxManager().removeSong(this.getId());
}
2019-05-26 20:14:53 +02:00
public boolean inQueue() {
2018-07-06 15:30:00 +02:00
return this.inQueue;
}
2019-05-26 20:14:53 +02:00
public void inQueue(boolean inQueue) {
2018-07-06 15:30:00 +02:00
this.inQueue = inQueue;
}
}