Extend Metronome Plugin with configurable sound and tick delay (#454)
* Extend Metronome Plugin with configurable sound and tick delay
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
||||||
|
* Copyright (c) 2018, oplosthee <https://github.com/oplosthee>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -27,13 +28,10 @@ package net.runelite.client.plugins.metronome;
|
|||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.SoundEffectID;
|
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -42,34 +40,14 @@ import javax.inject.Inject;
|
|||||||
)
|
)
|
||||||
public class MetronomePlugin extends Plugin
|
public class MetronomePlugin extends Plugin
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MetronomePlugin.class);
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MetronomePluginConfiguration config;
|
MetronomePluginConfiguration config;
|
||||||
|
|
||||||
private boolean tock = false;
|
private int tickCounter = 0;
|
||||||
|
private boolean shouldTock = false;
|
||||||
@Subscribe
|
|
||||||
void onTick(GameTick tick)
|
|
||||||
{
|
|
||||||
if (!config.enabled())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (tock)
|
|
||||||
{
|
|
||||||
client.playSoundEffect(SoundEffectID.GE_DECREMENT_PLOP);
|
|
||||||
}
|
|
||||||
else // tick
|
|
||||||
{
|
|
||||||
client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
tock = !tock;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
MetronomePluginConfiguration provideConfig(ConfigManager configManager)
|
MetronomePluginConfiguration provideConfig(ConfigManager configManager)
|
||||||
@@ -77,4 +55,25 @@ public class MetronomePlugin extends Plugin
|
|||||||
return configManager.getConfig(MetronomePluginConfiguration.class);
|
return configManager.getConfig(MetronomePluginConfiguration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
void onTick(GameTick tick)
|
||||||
|
{
|
||||||
|
if (!config.enabled() || config.tickCount() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++tickCounter % config.tickCount() == 0)
|
||||||
|
{
|
||||||
|
if (config.enableTock() && shouldTock)
|
||||||
|
{
|
||||||
|
client.playSoundEffect(config.tockSound());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.playSoundEffect(config.tickSound());
|
||||||
|
}
|
||||||
|
shouldTock = !shouldTock;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
||||||
|
* Copyright (c) 2018, oplosthee <https://github.com/oplosthee>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -24,24 +25,70 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.metronome;
|
package net.runelite.client.plugins.metronome;
|
||||||
|
|
||||||
|
import net.runelite.api.SoundEffectID;
|
||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
|
||||||
@ConfigGroup(
|
@ConfigGroup(
|
||||||
keyName = "metronomeplugin",
|
keyName = "metronome",
|
||||||
name = "Metronome plugin",
|
name = "Metronome",
|
||||||
description = "Configuration for the metronome plugin"
|
description = "Plays a sound on the specified tick to aid in efficient skilling"
|
||||||
)
|
)
|
||||||
public interface MetronomePluginConfiguration extends Config
|
public interface MetronomePluginConfiguration extends Config
|
||||||
{
|
{
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "enabled",
|
keyName = "enabled",
|
||||||
name = "Enable metronome",
|
name = "Enable metronome",
|
||||||
description = "Toggles tick metronome"
|
description = "Toggles tick metronome",
|
||||||
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean enabled()
|
default boolean enabled()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "tickCount",
|
||||||
|
name = "Tick count",
|
||||||
|
description = "Configures the tick on which a sound will be played",
|
||||||
|
position = 2
|
||||||
|
)
|
||||||
|
default int tickCount()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "tickSound",
|
||||||
|
name = "Tick sound ID",
|
||||||
|
description = "Configures which sound to play on the specified tick",
|
||||||
|
position = 3
|
||||||
|
)
|
||||||
|
default int tickSound()
|
||||||
|
{
|
||||||
|
return SoundEffectID.GE_INCREMENT_PLOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "enableTock",
|
||||||
|
name = "Enable tock (alternating) sound",
|
||||||
|
description = "Toggles whether to play two alternating sounds",
|
||||||
|
position = 4
|
||||||
|
)
|
||||||
|
default boolean enableTock()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "tockSound",
|
||||||
|
name = "Tock sound ID",
|
||||||
|
description = "Configures which sound to alternate between",
|
||||||
|
position = 5
|
||||||
|
)
|
||||||
|
default int tockSound()
|
||||||
|
{
|
||||||
|
return SoundEffectID.GE_DECREMENT_PLOP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user