From f7196df08b2db509723e793741c8d41c08e1271b Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Sun, 26 May 2019 20:00:47 +0300 Subject: [PATCH] Add MusicPlayer achievement --- .../interactions/InteractionJukeBox.java | 2 +- .../habbo/habbohotel/rooms/TraxManager.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java index 55bcfcbf..57fffaa4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java @@ -63,7 +63,7 @@ public class InteractionJukeBox extends HabboItem room.getTraxManager().stop(); } else { - room.getTraxManager().play(0); + room.getTraxManager().play(0, client.getHabbo()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 5387e341..db20caac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; 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.interactions.InteractionJukeBox; import com.eu.habbo.habbohotel.items.interactions.InteractionMusicDisc; @@ -26,6 +27,8 @@ public class TraxManager implements Disposable private int startedTimestamp = 0; private InteractionMusicDisc currentlyPlaying = null; private int playingIndex = 0; + private int cycleStartedTimestamp = 0; + private Habbo starter = null; private boolean disposed = false; @@ -78,6 +81,11 @@ public class TraxManager implements Disposable } public void play(int index) + { + this.play(index, null); + } + + public void play(int index, Habbo starter) { if (this.currentlyPlaying == null) { @@ -99,6 +107,11 @@ public class TraxManager implements Disposable this.room.setJukeBoxActive(true); this.startedTimestamp = Emulator.getIntUnixTimestamp(); 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()); @@ -111,9 +124,15 @@ public class TraxManager implements Disposable 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.currentlyPlaying = null; this.startedTimestamp = 0; + this.cycleStartedTimestamp = 0; + this.starter = null; this.playingIndex = 0; for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class))