Initial commit
This commit is contained in:
52
prayerflick/prayerflick.gradle.kts
Normal file
52
prayerflick/prayerflick.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.1.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Prayer Flicking" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Flicks prayer" // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes(mapOf(
|
||||
"Plugin-Version" to project.version,
|
||||
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
|
||||
"Plugin-Provider" to project.extra["PluginProvider"],
|
||||
"Plugin-Description" to project.extra["PluginDescription"],
|
||||
"Plugin-Dependencies" to
|
||||
arrayOf(
|
||||
nameToId("Chaos Util"),
|
||||
nameToId("iUtils")
|
||||
).joinToString(),
|
||||
"Plugin-License" to project.extra["PluginLicense"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.prayerflick;
|
||||
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Keybind;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("ChaosPrayerflickConfig")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "hotkey",
|
||||
name = "Flick hotkey",
|
||||
description = "When you press this key prayer flicking will start",
|
||||
position = 0
|
||||
)
|
||||
default Keybind hotkey() {
|
||||
return new Keybind(KeyEvent.VK_BACK_SLASH, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "deactivateAfterStopping",
|
||||
name = "Deactivate prayers after stopping",
|
||||
description = "Deactivate prayers after stopping prayer flicking.",
|
||||
position = 10
|
||||
)
|
||||
default boolean deactivateAfterStopping() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMelee",
|
||||
name = "Melee hotkey",
|
||||
description = "When you press this key protect from melee will be set as quickprayer",
|
||||
position = 20
|
||||
)
|
||||
default Keybind hotkeyMelee() {
|
||||
return new Keybind(KeyEvent.VK_1, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMissiles",
|
||||
name = "Missiles hotkey",
|
||||
description = "When you press this key protect from missiles will be set as quickprayer",
|
||||
position = 21
|
||||
)
|
||||
default Keybind hotkeyMissiles() {
|
||||
return new Keybind(KeyEvent.VK_2, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMagic",
|
||||
name = "Magic hotkey",
|
||||
description = "When you press this key protect from magic will be set as quickprayer",
|
||||
position = 22
|
||||
)
|
||||
default Keybind hotkeyMagic() {
|
||||
return new Keybind(KeyEvent.VK_3, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "openInventory",
|
||||
name = "Open inventory",
|
||||
description = "Open inventory after swapping quickprayers",
|
||||
position = 23
|
||||
)
|
||||
default boolean openInventory() { return true; }
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package io.reisub.openosrs.prayerflick;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Calculations;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.input.KeyListener;
|
||||
import net.runelite.client.input.KeyManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.game.Game;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Prayer Flicking",
|
||||
description = "",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Prayerflick extends Plugin implements KeyListener {
|
||||
@Inject
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Inject
|
||||
private KeyManager keyManager;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Inject
|
||||
private Calculations calc;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
private boolean toggleFlicking;
|
||||
private boolean firstFlick;
|
||||
private boolean toggledOff;
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
log.info("Starting Chaos Prayer Flicking");
|
||||
|
||||
keyManager.registerKeyListener(this);
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() {
|
||||
log.info("Stopping Chaos Prayer Flicking");
|
||||
|
||||
keyManager.unregisterKeyListener(this);
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (client == null || client.getGameState() == null || client.getGameState() != GameState.LOGGED_IN || executor == null) return;
|
||||
|
||||
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayers == null) return;
|
||||
|
||||
if (toggleFlicking && quickPrayers.actions()!= null) {
|
||||
boolean active = quickPrayers.actions().get(0).equals("Deactivate");
|
||||
|
||||
if (!active && !firstFlick) {
|
||||
toggle(calc.random(1, 15), quickPrayers);
|
||||
return;
|
||||
}
|
||||
|
||||
toggle(calc.random(1, 9), quickPrayers);
|
||||
toggle(calc.random(90, 100), quickPrayers);
|
||||
|
||||
if (firstFlick) {
|
||||
firstFlick = false;
|
||||
}
|
||||
} else if (!toggleFlicking && toggledOff && config.deactivateAfterStopping()) {
|
||||
toggledOff = false;
|
||||
toggle(calc.random(90, 110), quickPrayers);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggle(int delay, iWidget widget) {
|
||||
executor.schedule(() -> {
|
||||
widget.interact(0);
|
||||
}, delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.hotkey().matches(e)) {
|
||||
if (toggleFlicking) {
|
||||
toggledOff = true;
|
||||
} else {
|
||||
firstFlick = true;
|
||||
}
|
||||
|
||||
toggleFlicking = !toggleFlicking;
|
||||
} else if (config.hotkeyMelee().matches(e)) {
|
||||
setPrayer(14);
|
||||
} else if (config.hotkeyMissiles().matches(e)) {
|
||||
setPrayer(13);
|
||||
} else if (config.hotkeyMagic().matches(e)) {
|
||||
setPrayer(12);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {}
|
||||
|
||||
private void setPrayer(int childId) {
|
||||
executor.schedule(() -> {
|
||||
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayers == null) return;
|
||||
|
||||
quickPrayers.interact(1);
|
||||
game.waitUntil(() -> {
|
||||
iWidget w = game.widget(77, 4);
|
||||
return w != null && !w.hidden();
|
||||
});
|
||||
|
||||
iWidget protection = game.widget(77, 4, childId);
|
||||
if (protection == null) return;
|
||||
|
||||
protection.interact(0);
|
||||
|
||||
iWidget update = game.widget(77, 5);
|
||||
if (update == null) return;
|
||||
|
||||
update.interact(0);
|
||||
|
||||
if (config.openInventory()) {
|
||||
game.openInterface(3);
|
||||
}
|
||||
}, 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user