Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Custom Music options in Dungeons #148

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/me/Danker/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,18 @@ public static int toDisplay(String value) {
)
public static int dungeonBossVolume = 50;

@CfgName(
name = "Phase1Volume",
category = "music"
)
@Slider(
name = "F7 Phase 1 Music Volume",
min = 0, max = 100,
category = "Music",
subcategory = "Music"
)
public static int phase1Volume = 50;

@CfgName(
name = "Phase2Volume",
category = "music"
Expand Down
38 changes: 34 additions & 4 deletions src/main/java/me/Danker/features/CustomMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class CustomMusic {
public static Song dungeonboss;
public static Song bloodroom;
public static Song dungeon;
public static Song phase1;
public static Song phase2;
public static Song phase3;
public static Song phase4;
Expand All @@ -53,6 +54,10 @@ public class CustomMusic {

static int curPhase = 0;

// Once the lightning strikes, the music in the blood room should stop playing.
// We start waiting for it when the Watcher says his last line.
static boolean awaitingLightning = false;

@SubscribeEvent
public void onWorldChange(WorldEvent.Load event) {
reset();
Expand All @@ -78,8 +83,13 @@ public void onTick(TickEvent.ClientTickEvent event) throws UnsupportedAudioFileE
secondLine.contains("- Healthy") || // F3
firstLine.contains("30,344") || // F4
firstLine.contains("livid") || // F5
firstLine.contains("sadan") || // F6
firstLine.contains("maxor") || // F7
firstLine.contains("sadan")) { // F6

if (ModConfig.dungeonBossMusic && curPhase != -1) {
dungeonboss.start();
}

} else if (firstLine.contains("maxor") || // F7
firstLine.contains("f7")) {

if (ModConfig.dungeonBossMusic) {
Expand All @@ -98,8 +108,9 @@ public void onTick(TickEvent.ClientTickEvent event) throws UnsupportedAudioFileE
case 5:
phase5.start();
break;
case 1:
default:
dungeonboss.start();
phase1.start();
}
}
}
Expand Down Expand Up @@ -166,7 +177,10 @@ public void onChat(ClientChatReceivedEvent event) throws UnsupportedAudioFileExc

if (Utils.isInDungeons()) {
if (ModConfig.dungeonBossMusic) {
if (phase2.hasSongs() && message.startsWith("[BOSS] Storm: Pathetic Maxor")) {
if (phase1.hasSongs() && message.startsWith("[BOSS] Maxor: WELL WELL WELL")) { // he says more but apostrophes are annoying to deal with sometimes
phase1.start();
curPhase = 1;
} else if (phase2.hasSongs() && message.startsWith("[BOSS] Storm: Pathetic Maxor")) {
phase2.start();
curPhase = 2;
} else if (phase3.hasSongs() && message.startsWith("[BOSS] Goldor: Who dares trespass into my domain?")) {
Expand All @@ -181,13 +195,20 @@ public void onChat(ClientChatReceivedEvent event) throws UnsupportedAudioFileExc
}
}

if (ModConfig.bloodRoomMusic) {
if (message.startsWith("[BOSS] The Watcher: You have proven yourself. You may pass")) {
awaitingLightning = true;
}
}

if (message.contains(":")) return;

if (message.contains("EXTRA STATS ")) {
curPhase = -1; // force no play
dungeonboss.stop();
bloodroom.stop();
dungeon.stop();
phase1.stop();
phase2.stop();
phase3.stop();
phase4.stop();
Expand All @@ -204,6 +225,13 @@ public void onSound(PlaySoundEvent event) {
if (ModConfig.disableHypixelMusic && cancelNotes && event.name.startsWith("note.")) {
event.result = null;
}

// If we're awaiting the lightning, we should stop the music.
// This could be a false positive due to stormy mobs, but it wouldn't make much of a difference.
if (awaitingLightning && event.name.equals("ambient.weather.thunder")) {
awaitingLightning = false;
if (bloodroom != null) bloodroom.stop();
}
Comment on lines +228 to +234
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use PacketReadEvent instead of PlaySoundEvent as it doesn't fire if the player has sounds disabled. See how it's implemented here https://github.com/bowser0000/SkyblockMod/blob/development/src/main/java/me/Danker/features/loot/LootTracker.java#L47

}

@SubscribeEvent
Expand All @@ -221,6 +249,7 @@ public static void init(String configDirectory) {
dungeonboss = new Song(directory, "dungeonboss", ModConfig.dungeonBossVolume);
bloodroom = new Song(directory, "bloodroom", ModConfig.bloodRoomVolume);
dungeon = new Song(directory, "dungeon", ModConfig.dungeonVolume);
phase1 = new Song(directory, "phaseone", ModConfig.phase1Volume);
phase2 = new Song(directory, "phasetwo", ModConfig.phase2Volume);
phase3 = new Song(directory, "phasethree", ModConfig.phase3Volume);
phase4 = new Song(directory, "phasefour", ModConfig.phase4Volume);
Expand All @@ -245,6 +274,7 @@ public static void reset() {
if (dungeonboss != null) dungeonboss.stop();
if (bloodroom != null) bloodroom.stop();
if (dungeon != null) dungeon.stop();
if (phase1 != null) phase1.stop();
if (phase2 != null) phase2.stop();
if (phase3 != null) phase3.stop();
if (phase4 != null) phase4.stop();
Expand Down