Merge pull request #118 from Kyleeld/master

location to cc plugin
This commit is contained in:
James
2019-04-25 15:32:46 -07:00
committed by GitHub
6 changed files with 1652 additions and 1505 deletions

View File

@@ -0,0 +1,16 @@
package net.runelite.client.plugins.locationchatter;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind;
@ConfigGroup("locationchatter")
public interface LocationChatterConfig extends Config
{
@ConfigItem(keyName = "keybind", name = "Send to CC", description = "Configure button to send current location to CC")
default Keybind keybind()
{
return Keybind.NOT_SET;
}
}

View File

@@ -0,0 +1,140 @@
package net.runelite.client.plugins.locationchatter;
import com.google.inject.Provides;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.ScriptID;
import net.runelite.api.VarClientStr;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.VarClientStrChanged;
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.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginManager;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.wildernesslocations.WildernessLocationsPlugin;
import net.runelite.client.util.HotkeyListener;
import javax.inject.Inject;
@Slf4j
@PluginDescriptor(
name = "Location Chatter",
tags = {"location", "exilent", "pklite", "spammer"},
type = PluginType.UTILITY
)
public class LocationChatterPlugin extends Plugin
{
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Inject
LocationChatterConfig config;
@Inject
private KeyManager keyManager;
@Inject
private PluginManager pluginManager;
private WildernessLocationsPlugin wildyLocsPlugin;
private String oldChat = "";
private int currentCooldown = 0;
private final int COOLDOWN_TICKS = 30;
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.keybind())
{
@Override
public void hotkeyPressed()
{
sendLocToCC();
}
};
@Override
public void startUp()
{
for (Plugin pl : pluginManager.getPlugins())
{
if (pl instanceof WildernessLocationsPlugin)
{
wildyLocsPlugin = (WildernessLocationsPlugin) pl;
}
}
keyManager.registerKeyListener(hotkeyListener);
}
@Override
public void shutDown()
{
keyManager.unregisterKeyListener(hotkeyListener);
}
@Provides
LocationChatterConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(LocationChatterConfig.class);
}
@Subscribe
public void onGameTick(GameTick tickEvent)
{
if (currentCooldown != 0)
{
currentCooldown--;
}
}
@Subscribe
public void onVarClientStrChanged(VarClientStrChanged varClient)
{
String newChat = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
if (varClient.getIndex() == VarClientStr.CHATBOX_TYPED_TEXT.getIndex() && !newChat.equals(oldChat))
{
oldChat = newChat;
}
}
private boolean inClanChat()
{
return client.getWidget(WidgetInfo.CLAN_CHAT_TITLE) != null;
}
private void sendMessage(String text)
{
int mode = 0;
if (inClanChat() && text.startsWith("/"))
{
mode = 2;
}
int finalMode = mode;
Runnable r = () ->
{
String cached = oldChat;
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, text);
client.runScript(ScriptID.CHATBOX_INPUT, finalMode, text);
oldChat = cached;
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, oldChat);
};
clientThread.invoke(r);
}
private void sendLocToCC()
{
String location = wildyLocsPlugin.getLocationString();
if (location.equals(""))
{
return;
}
sendMessage("/World: " + client.getWorld() + " Location: " + location);
currentCooldown = COOLDOWN_TICKS;
}
}

View File

@@ -1,147 +1,135 @@
/*
* Copyright (c) 2019. PKLite - All Rights Reserved
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
* Proprietary and confidential. Refer to PKLite License file for more information on
* full terms of this copyright and to determine what constitutes authorized use.
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.pvptools;
import java.awt.Color;
import java.security.Key;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind;
@ConfigGroup("pvptools")
public interface PvpToolsConfig extends Config
{
@ConfigItem(
keyName = "countPlayers",
name = "Count Players",
description = "When in PvP zones, counts the attackable players in and not in player's CC",
position = 3
)
default boolean countPlayers()
{
return true;
}
@ConfigItem(
keyName = "countOverHeads",
name = "Count Enemy Overheads",
description = "Counts the number of each protection prayer attackable targets not in your CC are currently" +
" using",
position = 4
)
default boolean countOverHeads()
{
return true;
}
@ConfigItem(
keyName = "fallInHelper",
name = "Fall In Helper",
description = "Hides all non-friendly player entities other than the one that is attacking you.",
position = 5
)
default boolean fallInHelper()
{
return true;
}
@ConfigItem(
keyName = "hotkey",
name = "Fall In Hotkey",
description = "Turns the fall in helper on or off when you press this hotkey",
position = 6
)
default Keybind hotkey()
{
return Keybind.NOT_SET;
}
@ConfigItem(
keyName = "attackOptionsClan",
name = "Move CC Attack Option",
description = "Moves the attack option for people in the same CC",
position = 7,
group = "Right-Click Attack Options"
)
default boolean attackOptionsClan()
{
return false;
}
@ConfigItem(
keyName = "attackOptionsFriend",
name = "Move Friend Attack Options",
description = "Moves the attack option for people on your friends list",
position = 8,
group = "Right-Click Attack Options"
)
default boolean attackOptionsFriend()
{
return false;
}
@ConfigItem(
keyName = "attackOptionsHotkey",
name = "Attack Option Hotkey",
description = "Enables a hotkey for attack options to disable or enable hiding quickly",
position = 10,
group = "Right-Click Attack Options"
)
default Keybind attackOptionsHotkey()
{
return Keybind.CTRL;
}
@ConfigItem(
keyName = "levelRangeAttackOptions",
name = "Moves Other Attack Options",
description = "Moves the attack option for people that are outside your level range",
position = 9,
group = "Right-Click Attack Options"
)
default boolean levelRangeAttackOptions()
{
return false;
}
@ConfigItem(
keyName = "riskCalculator",
name = "Risk Calculator",
description = "Enables a panel in the PvP Tools Panel that shows the players current risk",
position = 13
)
default boolean riskCalculatorEnabled()
{
return true;
}
@ConfigItem(
keyName = "missingPlayers",
name = "Missing CC Players",
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at" +
" the current players location",
position = 14
)
default boolean missingPlayersEnabled() { return true; }
@ConfigItem(
keyName = "currentPlayers",
name = "Current CC Players",
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members currently at" +
" the players location",
position = 15
)
default boolean currentPlayersEnabled()
{
return true;
}
}
/*
* Copyright (c) 2019. PKLite - All Rights Reserved
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
* Proprietary and confidential. Refer to PKLite License file for more information on
* full terms of this copyright and to determine what constitutes authorized use.
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
*
*/
package net.runelite.client.plugins.pvptools;
import java.awt.Color;
import java.security.Key;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Keybind;
@ConfigGroup("pvptools")
public interface PvpToolsConfig extends Config
{
@ConfigItem(
keyName = "countPlayers",
name = "Count Players",
description = "When in PvP zones, counts the attackable players in and not in player's CC",
position = 3
)
default boolean countPlayers()
{
return true;
}
@ConfigItem(
keyName = "countOverHeads",
name = "Count Enemy Overheads",
description = "Counts the number of each protection prayer attackable targets not in your CC are currently" +
" using",
position = 4
)
default boolean countOverHeads()
{
return true;
}
@ConfigItem(
keyName = "fallInHelper",
name = "Fall In Helper",
description = "Hides all non-friendly player entities other than the one that is attacking you.",
position = 5
)
default boolean fallInHelper()
{
return true;
}
@ConfigItem(
keyName = "hotkey",
name = "Fall In Hotkey",
description = "Turns the fall in helper on or off when you press this hotkey",
position = 6
)
default Keybind hotkey()
{
return Keybind.NOT_SET;
}
@ConfigItem(
keyName = "attackOptionsClan",
name = "Move CC Attack Option",
description = "Moves the attack option for people in the same CC",
position = 7,
group = "Right-Click Attack Options"
)
default boolean attackOptionsClan()
{
return false;
}
@ConfigItem(
keyName = "attackOptionsFriend",
name = "Move Friend Attack Options",
description = "Moves the attack option for people on your friends list",
position = 8,
group = "Right-Click Attack Options"
)
default boolean attackOptionsFriend()
{
return false;
}
@ConfigItem(
keyName = "levelRangeAttackOptions",
name = "Moves Other Attack Options",
description = "Moves the attack option for people that are outside your level range",
position = 9,
group = "Right-Click Attack Options"
)
default boolean levelRangeAttackOptions()
{
return false;
}
@ConfigItem(
keyName = "riskCalculator",
name = "Risk Calculator",
description = "Enables a panel in the PvP Tools Panel that shows the players current risk",
position = 13
)
default boolean riskCalculatorEnabled()
{
return true;
}
@ConfigItem(
keyName = "missingPlayers",
name = "Missing CC Players",
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at" +
" the current players location",
position = 14
)
default boolean missingPlayersEnabled() { return true; }
@ConfigItem(
keyName = "currentPlayers",
name = "Current CC Players",
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members currently at" +
" the players location",
position = 15
)
default boolean currentPlayersEnabled()
{
return true;
}
}

View File

@@ -1,130 +1,136 @@
package net.runelite.client.plugins.wildernesslocations;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import javax.inject.Inject;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.GameTick;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.wildernesslocations.WildernessLocationsOverlay;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.WildernessLocation;
@PluginDescriptor(name="PvP Wild Locations",
description="Indicates the players current location in the wild",
tags={"Wildy,", "Wilderness Location", "location", "loc", "pvp", "pklite"},
type = PluginType.PVP
@PluginDescriptor(
name = "Wild Locations",
description = "Indicates the players current location in the wild",
tags = {"Wildy", "Wilderness Location", "location", "loc", "pvp", "pklite"},
type = PluginType.PVP
)
public class WildernessLocationsPlugin extends Plugin {
@Inject
private Client client;
@Inject
OverlayManager overlayManager;
@Inject
private WildernessLocationsOverlay overlay;
private final HashMap<WorldArea, String> wildLocs;
private boolean renderLocation;
private String locationString;
private WorldPoint worldPoint;
private static int UPDATE_INTERVAL = 3;
public WildernessLocationsPlugin() {
overlay = new WildernessLocationsOverlay(client, this);
wildLocs = WildernessLocationsPlugin.getLocationMap();
locationString = "";
worldPoint = null;
}
@Override
protected void startUp() throws Exception {
overlayManager.add(overlay);
}
@Override
protected void shutDown() throws Exception {
overlayManager.add(overlay);
}
@Subscribe
public void onGameTick(GameTick event) {
if (UPDATE_INTERVAL > 0) {
--UPDATE_INTERVAL;
return;
}
boolean bl = renderLocation = client.getVar(Varbits.IN_WILDERNESS) == 1;
if (renderLocation) {
if (client.getLocalPlayer().getWorldLocation() != worldPoint) {
locationString = location();
worldPoint = client.getLocalPlayer().getWorldLocation();
}
} else {
worldPoint = null;
locationString = "";
}
UPDATE_INTERVAL = 3;
}
private String location() {
int dist = 10000;
String s = "";
WorldArea closestArea = null;
for (Map.Entry<WorldArea, String> entry : wildLocs.entrySet()) {
WorldArea worldArea = entry.getKey();
if (worldArea.toWorldPointList().contains(client.getLocalPlayer().getWorldLocation())) {
s = entry.getValue();
return s;
}
int distTo = worldArea.distanceTo(client.getLocalPlayer().getWorldLocation());
if (distTo >= dist) continue;
dist = distTo;
closestArea = worldArea;
}
if (client.getLocalPlayer().getWorldLocation().getY() > ((WorldArea)Objects.requireNonNull(closestArea)).toWorldPoint().getY() + closestArea.getHeight()) {
s = s + "N";
}
if (client.getLocalPlayer().getWorldLocation().getY() < closestArea.toWorldPoint().getY()) {
s = s + "S";
}
if (client.getLocalPlayer().getWorldLocation().getX() < closestArea.toWorldPoint().getX()) {
s = s + "W";
}
if (client.getLocalPlayer().getWorldLocation().getX() > closestArea.toWorldPoint().getX() + closestArea.getWidth()) {
s = s + "E";
}
s = s + " of ";
if ((s = s + wildLocs.get(closestArea)).startsWith(" of ")) {
s = s.substring(3);
}
return s;
}
private static HashMap<WorldArea, String> getLocationMap() {
HashMap<WorldArea, String> hashMap = new HashMap<WorldArea, String>();
Arrays.stream(WildernessLocation.values()).forEach(wildernessLocation -> hashMap.put(wildernessLocation.getWorldArea(), wildernessLocation.getName()));
return hashMap;
}
public boolean isRenderLocation() {
return renderLocation;
}
public String getLocationString() {
return locationString;
}
public class WildernessLocationsPlugin extends Plugin
{
@Inject
private Client client;
@Inject
OverlayManager overlayManager;
@Inject
private WildernessLocationsOverlay overlay = new WildernessLocationsOverlay(this.client, this);
private final HashMap<WorldArea, String> wildLocs = getLocationMap();
@Getter
private boolean renderLocation;
@Getter
private String locationString = "";
private WorldPoint worldPoint = null;
@Override
protected void startUp() throws Exception
{
overlayManager.add(overlay);
}
@Override
protected void shutDown() throws Exception
{
overlayManager.remove(overlay);
}
@Subscribe
public void onGameTick(GameTick event)
{
renderLocation = client.getVar(Varbits.IN_WILDERNESS) == 1;
if (renderLocation)
{
if (client.getLocalPlayer().getWorldLocation() != worldPoint)
{
locationString = location();
worldPoint = client.getLocalPlayer().getWorldLocation();
}
}
else
{
worldPoint = null;
locationString = "";
}
}
private String location()
{
int dist = 10000;
String s = "";
WorldArea closestArea = null;
for (Map.Entry<WorldArea, String> entry : wildLocs.entrySet())
{
WorldArea worldArea = entry.getKey();
if (worldArea.toWorldPointList().contains(client.getLocalPlayer().getWorldLocation()))
{
s = entry.getValue();
return s;
}
int distTo = worldArea.distanceTo(client.getLocalPlayer().getWorldLocation());
if (distTo < dist)
{
dist = distTo;
closestArea = worldArea;
}
}
if (client.getLocalPlayer().getWorldLocation().getY() >
(Objects.requireNonNull(closestArea).toWorldPoint().getY() + closestArea.getHeight()))
{
s = s + "N";
}
if (client.getLocalPlayer().getWorldLocation().getY() < closestArea.toWorldPoint().getY())
{
s = s + "S";
}
if (client.getLocalPlayer().getWorldLocation().getX() < closestArea.toWorldPoint().getX())
{
s = s + "W";
}
if (client.getLocalPlayer().getWorldLocation().getX() >
(closestArea.toWorldPoint().getX() + closestArea.getWidth()))
{
s = s + "E";
}
s = s + " of ";
s = s + wildLocs.get(closestArea);
if (s.startsWith(" of "))
{
s = s.substring(3);
}
return s;
}
private static HashMap<WorldArea, String> getLocationMap()
{
HashMap<WorldArea, String> hashMap = new HashMap<>();
Arrays.stream(WildernessLocation.values()).forEach(wildernessLocation ->
hashMap.put(wildernessLocation.getWorldArea(), wildernessLocation.getName()));
return hashMap;
}
}