AB SO LUTE LY FIN ESS ING THE CUNT (#1559)

This commit is contained in:
ThatGamerBlue
2019-09-07 11:25:28 +01:00
committed by Kyle
parent 4608f08252
commit 231e41372e
2 changed files with 48 additions and 0 deletions

View File

@@ -27,6 +27,14 @@ package net.runelite.client.plugins.customcursor;
import com.google.inject.Provides;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus;
@@ -34,6 +42,9 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientUI;
import java.io.IOException;
@Slf4j
@PluginDescriptor(
name = "Custom Cursor",
description = "Replaces your mouse cursor image",
@@ -51,6 +62,9 @@ public class CustomCursorPlugin extends Plugin
@Inject
private EventBus eventBus;
private Clip skillSpecsRage;
private int volume = 35;
@Provides
CustomCursorConfig provideConfig(ConfigManager configManager)
{
@@ -62,6 +76,20 @@ public class CustomCursorPlugin extends Plugin
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
updateCursor();
try (AudioInputStream ais = AudioSystem.getAudioInputStream(this.getClass().getResourceAsStream("specs-rage.wav")))
{
skillSpecsRage = AudioSystem.getClip();
skillSpecsRage.open(ais);
FloatControl gain = (FloatControl) skillSpecsRage.getControl(FloatControl.Type.MASTER_GAIN);
float gainVal = (((float) volume) * 40f / 100f) - 35f;
gain.setValue(gainVal);
}
catch (UnsupportedAudioFileException | IOException | LineUnavailableException e)
{
log.warn("Error opening audiostream from specs-rage.wav", e);
skillSpecsRage = null;
}
}
@Override
@@ -78,11 +106,31 @@ public class CustomCursorPlugin extends Plugin
{
updateCursor();
}
if (event.getGroup().equals("metronome") && event.getKey().equals("volume"))
{
this.volume = Integer.parseInt(event.getNewValue());
}
}
private void updateCursor()
{
CustomCursor selectedCursor = config.selectedCursor();
if (selectedCursor == CustomCursor.SKILL_SPECS)
{
if (skillSpecsRage != null)
{
if (skillSpecsRage.isRunning())
{
skillSpecsRage.stop();
}
skillSpecsRage.setFramePosition(0);
skillSpecsRage.start();
}
}
clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString());
}
}