Merge branch 'dev' into 'master'

2.3.1

See merge request morningstar/Arcturus-Community!109
This commit is contained in:
Harmonic 2020-04-01 06:19:01 -04:00
commit e47a48eb3d
3 changed files with 24 additions and 17 deletions

View File

@ -94,7 +94,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
@Override @Override
public String getWiredData() { public String getWiredData() {
StringBuilder data = new StringBuilder(this.startRotation.getValue() + "\t" + this.rotateAction + "\t" + this.items.size()); StringBuilder data = new StringBuilder(this.getDelay() + this.startRotation.getValue() + "\t" + this.rotateAction + "\t" + this.items.size());
for (Map.Entry<HabboItem, RoomUserRotation> entry : this.items.entrySet()) { for (Map.Entry<HabboItem, RoomUserRotation> entry : this.items.entrySet()) {
data.append("\t").append(entry.getKey().getId()).append(":").append(entry.getValue().getValue()); data.append("\t").append(entry.getKey().getId()).append(":").append(entry.getValue().getValue());
@ -107,6 +107,9 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
public void loadWiredData(ResultSet set, Room room) throws SQLException { public void loadWiredData(ResultSet set, Room room) throws SQLException {
String[] data = set.getString("wired_data").split("\t"); String[] data = set.getString("wired_data").split("\t");
if (data.length >= 1) {
this.setDelay(Integer.valueOf(data[0]));
}
if (data.length >= 3) { if (data.length >= 3) {
this.startRotation = RoomUserRotation.fromValue(Integer.valueOf(data[0])); this.startRotation = RoomUserRotation.fromValue(Integer.valueOf(data[0]));
this.rotateAction = Integer.valueOf(data[1]); this.rotateAction = Integer.valueOf(data[1]);
@ -178,6 +181,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
this.items.put(item, this.startRotation); this.items.put(item, this.startRotation);
} }
} }
this.setDelay(packet.readInt());
return true; return true;
} }

View File

@ -857,7 +857,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (this.loaded) { if (this.loaded) {
try { try {
if (!this.traxManager.disposed()) {
if (this.traxManager != null && !this.traxManager.disposed()) {
this.traxManager.dispose(); this.traxManager.dispose();
} }

View File

@ -44,24 +44,26 @@ public class TraxManager implements Disposable {
try (ResultSet set = statement.executeQuery()) { try (ResultSet set = statement.executeQuery()) {
while (set.next()) { while (set.next()) {
HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id"));
if(musicDisc != null) {
if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) {
try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) {
stmt.setInt(1, this.room.getId());
stmt.setInt(2, musicDisc.getId());
stmt.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
return;
}
} else {
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId());
if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) { if (track != null) {
try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) { this.songs.add((InteractionMusicDisc) musicDisc);
stmt.setInt(1, this.room.getId()); this.totalLength += track.getLength();
stmt.setInt(2, musicDisc.getId()); }
stmt.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
return;
}
} else {
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId());
if (track != null) {
this.songs.add((InteractionMusicDisc) musicDisc);
this.totalLength += track.getLength();
} }
} }
} }
} }
} catch (SQLException e) { } catch (SQLException e) {