Skip to content

Commit

Permalink
Add Odablock Warriors (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
DapperMickie authored Jun 17, 2024
1 parent 2a986da commit ae34a25
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
}

group = 'com.github.dappermickie.odablock'
version = '1.1.1'
version = '1.1.2'


tasks.withType(JavaCompile) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/github/dappermickie/odablock/OdablockConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,18 @@ default boolean snowballed()
return true;
}

@ConfigItem(
keyName = "warriors",
name = "Odablock Warriors",
description = "Should the '7th Realm' in-game sound be replaced with the Odablock Warriors song?",
position = 30,
warning = "If you turn this off, you'll have to reload the client to be able to manually play '7th Realm' again."
)
default boolean warriors()
{
return true;
}

@ConfigSection(
name = "Tombs of Amascut",
description = "All the configurations regarding Tombs of Amascut.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.dappermickie.odablock.sounds.KillingPlayer;
import com.github.dappermickie.odablock.sounds.KillingRat;
import com.github.dappermickie.odablock.sounds.LevelUp;
import com.github.dappermickie.odablock.sounds.OdablockWarriors;
import com.github.dappermickie.odablock.sounds.Pet;
import com.github.dappermickie.odablock.sounds.PetDog;
import com.github.dappermickie.odablock.sounds.PkChest;
Expand Down Expand Up @@ -208,6 +209,10 @@ public class OdablockPlugin extends Plugin
@Inject
private KillingPlayer killingPlayer;

@Inject
private OdablockWarriors odablockWarriors;
// End of sound injections

@Inject
private LivestreamManager livestreamManager;

Expand All @@ -223,7 +228,6 @@ public class OdablockPlugin extends Plugin
@Inject
@Named("developerMode")
private boolean developerMode;
// End of sound injections

public static final String ODABLOCK = "Odablock";

Expand Down Expand Up @@ -395,6 +399,7 @@ public void onMenuOptionClicked(MenuOptionClicked menuOptionClicked)
reportPlayer.onMenuOptionClicked(menuOptionClicked);
declineTrade.onMenuOptionClicked(menuOptionClicked);
dismissRandomEvent.onMenuOptionClicked(menuOptionClicked);
odablockWarriors.onMenuOptionClicked(menuOptionClicked);
}

@Subscribe
Expand All @@ -407,6 +412,7 @@ public void onWidgetLoaded(WidgetLoaded event)

hairDresser.onWidgetLoaded(event);
pkChest.onWidgetLoaded(event);
odablockWarriors.onWidgetLoaded(event);
}

@Subscribe
Expand Down Expand Up @@ -537,6 +543,9 @@ public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
public void onCommandExecuted(CommandExecuted event)
{
emoteHandler.onCommandExecuted(event);
//if(event.getCommand().equals("loadwarrior")) {
// odablockWarriors.onWidgetLoaded(null);
//}
}

public static int TO_GROUP(int id)
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/github/dappermickie/odablock/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public enum Sound
HAIRDRESSER_SOUND_3("hairdresser", "Hairdresser_r3.wav"),

SNOWBALL_1("snowball", "Snowball_r1.wav"),
SNOWBALL_2("snowball", "Snowball_r2.wav");
SNOWBALL_2("snowball", "Snowball_r2.wav"),

WARRIOR("warriors", "odablock_warriors.wav");

private final String resourceName;
private final String directory;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.github.dappermickie.odablock.sounds;


import com.github.dappermickie.odablock.OdablockConfig;
import com.github.dappermickie.odablock.Sound;
import com.github.dappermickie.odablock.SoundEngine;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget;

public class OdablockWarriors
{
@Inject
private Client client;

@Inject
private SoundEngine soundEngine;

@Inject
private ScheduledExecutorService executor;

@Inject
private OdablockConfig config;

private Widget warriorWidget = null;

public void onWidgetLoaded(WidgetLoaded event)
{
if (!config.warriors())
{
return;
}
Widget musicWidget = client.getWidget(15663110);

if (musicWidget == null)
{
return;
}

for (Widget w : musicWidget.getDynamicChildren())
{
if (w.getText().equals("7th Realm") || w.getText().equals("Odablock Warriors"))
{
w.setText("Odablock Warriors");
w.setName("<col=ff9040>Odablock Warriors</col>");
w.setTextColor(901389);
w.revalidate();
warriorWidget = w;
return;
}
}
}

public void onMenuOptionClicked(MenuOptionClicked event)
{
if (warriorWidget == null)
{
return;
}
if (event.getWidget() != warriorWidget)
{
return;
}

event.consume();

soundEngine.playClip(Sound.WARRIOR, executor);
}
}

0 comments on commit ae34a25

Please sign in to comment.