Add MusicPlayer achievement

This commit is contained in:
Alejandro 2019-05-26 20:00:47 +03:00
parent 6caadebe33
commit f7196df08b
2 changed files with 20 additions and 1 deletions

View File

@ -63,7 +63,7 @@ public class InteractionJukeBox extends HabboItem
room.getTraxManager().stop(); room.getTraxManager().stop();
} else } else
{ {
room.getTraxManager().play(0); room.getTraxManager().play(0, client.getHabbo());
} }
} }
} }

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.core.Disposable; import com.eu.habbo.core.Disposable;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.SoundTrack; import com.eu.habbo.habbohotel.items.SoundTrack;
import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox; import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox;
import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc;
@ -26,6 +27,8 @@ public class TraxManager implements Disposable
private int startedTimestamp = 0; private int startedTimestamp = 0;
private InteractionMusicDisc currentlyPlaying = null; private InteractionMusicDisc currentlyPlaying = null;
private int playingIndex = 0; private int playingIndex = 0;
private int cycleStartedTimestamp = 0;
private Habbo starter = null;
private boolean disposed = false; private boolean disposed = false;
@ -78,6 +81,11 @@ public class TraxManager implements Disposable
} }
public void play(int index) public void play(int index)
{
this.play(index, null);
}
public void play(int index, Habbo starter)
{ {
if (this.currentlyPlaying == null) if (this.currentlyPlaying == null)
{ {
@ -99,6 +107,11 @@ public class TraxManager implements Disposable
this.room.setJukeBoxActive(true); this.room.setJukeBoxActive(true);
this.startedTimestamp = Emulator.getIntUnixTimestamp(); this.startedTimestamp = Emulator.getIntUnixTimestamp();
this.playingIndex = index; this.playingIndex = index;
if (starter != null) {
this.starter = starter;
this.cycleStartedTimestamp = Emulator.getIntUnixTimestamp();
}
} }
this.room.sendComposer(new JukeBoxNowPlayingMessageComposer(Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.currentlyPlaying.getSongId()), this.playingIndex, 0).compose()); this.room.sendComposer(new JukeBoxNowPlayingMessageComposer(Emulator.getGameEnvironment().getItemManager().getSoundTrack(this.currentlyPlaying.getSongId()), this.playingIndex, 0).compose());
@ -111,9 +124,15 @@ public class TraxManager implements Disposable
public void stop() public void stop()
{ {
if (this.starter != null && this.cycleStartedTimestamp > 0) {
AchievementManager.progressAchievement(this.starter, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicPlayer"), (Emulator.getIntUnixTimestamp() - cycleStartedTimestamp) / 60);
}
this.room.setJukeBoxActive(false); this.room.setJukeBoxActive(false);
this.currentlyPlaying = null; this.currentlyPlaying = null;
this.startedTimestamp = 0; this.startedTimestamp = 0;
this.cycleStartedTimestamp = 0;
this.starter = null;
this.playingIndex = 0; this.playingIndex = 0;
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class)) for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class))