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 * Copyright (c) 2019. PKLite - All Rights Reserved
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited. * 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 * Proprietary and confidential. Refer to PKLite License file for more information on
* full terms of this copyright and to determine what constitutes authorized use. * full terms of this copyright and to determine what constitutes authorized use.
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019 * Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
* *
*/ */
package net.runelite.client.plugins.pvptools; package net.runelite.client.plugins.pvptools;
import java.awt.Color; import java.awt.Color;
import java.security.Key; import java.security.Key;
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;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
@ConfigGroup("pvptools") @ConfigGroup("pvptools")
public interface PvpToolsConfig extends Config public interface PvpToolsConfig extends Config
{ {
@ConfigItem( @ConfigItem(
keyName = "countPlayers", keyName = "countPlayers",
name = "Count Players", name = "Count Players",
description = "When in PvP zones, counts the attackable players in and not in player's CC", description = "When in PvP zones, counts the attackable players in and not in player's CC",
position = 3 position = 3
) )
default boolean countPlayers() default boolean countPlayers()
{ {
return true; return true;
} }
@ConfigItem( @ConfigItem(
keyName = "countOverHeads", keyName = "countOverHeads",
name = "Count Enemy Overheads", name = "Count Enemy Overheads",
description = "Counts the number of each protection prayer attackable targets not in your CC are currently" + description = "Counts the number of each protection prayer attackable targets not in your CC are currently" +
" using", " using",
position = 4 position = 4
) )
default boolean countOverHeads() default boolean countOverHeads()
{ {
return true; return true;
} }
@ConfigItem( @ConfigItem(
keyName = "fallInHelper", keyName = "fallInHelper",
name = "Fall In Helper", name = "Fall In Helper",
description = "Hides all non-friendly player entities other than the one that is attacking you.", description = "Hides all non-friendly player entities other than the one that is attacking you.",
position = 5 position = 5
) )
default boolean fallInHelper() default boolean fallInHelper()
{ {
return true; return true;
} }
@ConfigItem( @ConfigItem(
keyName = "hotkey", keyName = "hotkey",
name = "Fall In Hotkey", name = "Fall In Hotkey",
description = "Turns the fall in helper on or off when you press this hotkey", description = "Turns the fall in helper on or off when you press this hotkey",
position = 6 position = 6
) )
default Keybind hotkey() default Keybind hotkey()
{ {
return Keybind.NOT_SET; return Keybind.NOT_SET;
} }
@ConfigItem( @ConfigItem(
keyName = "attackOptionsClan", keyName = "attackOptionsClan",
name = "Move CC Attack Option", name = "Move CC Attack Option",
description = "Moves the attack option for people in the same CC", description = "Moves the attack option for people in the same CC",
position = 7, position = 7,
group = "Right-Click Attack Options" group = "Right-Click Attack Options"
) )
default boolean attackOptionsClan() default boolean attackOptionsClan()
{ {
return false; return false;
} }
@ConfigItem( @ConfigItem(
keyName = "attackOptionsFriend", keyName = "attackOptionsFriend",
name = "Move Friend Attack Options", name = "Move Friend Attack Options",
description = "Moves the attack option for people on your friends list", description = "Moves the attack option for people on your friends list",
position = 8, position = 8,
group = "Right-Click Attack Options" group = "Right-Click Attack Options"
) )
default boolean attackOptionsFriend() default boolean attackOptionsFriend()
{ {
return false; return false;
} }
@ConfigItem( @ConfigItem(
keyName = "attackOptionsHotkey", keyName = "levelRangeAttackOptions",
name = "Attack Option Hotkey", name = "Moves Other Attack Options",
description = "Enables a hotkey for attack options to disable or enable hiding quickly", description = "Moves the attack option for people that are outside your level range",
position = 10, position = 9,
group = "Right-Click Attack Options" group = "Right-Click Attack Options"
) )
default Keybind attackOptionsHotkey() default boolean levelRangeAttackOptions()
{ {
return Keybind.CTRL; return false;
} }
@ConfigItem( @ConfigItem(
keyName = "levelRangeAttackOptions", keyName = "riskCalculator",
name = "Moves Other Attack Options", name = "Risk Calculator",
description = "Moves the attack option for people that are outside your level range", description = "Enables a panel in the PvP Tools Panel that shows the players current risk",
position = 9, position = 13
group = "Right-Click Attack Options" )
) default boolean riskCalculatorEnabled()
default boolean levelRangeAttackOptions() {
{ return true;
return false; }
}
@ConfigItem(
@ConfigItem( keyName = "missingPlayers",
keyName = "riskCalculator", name = "Missing CC Players",
name = "Risk Calculator", description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at" +
description = "Enables a panel in the PvP Tools Panel that shows the players current risk", " the current players location",
position = 13 position = 14
) )
default boolean riskCalculatorEnabled() default boolean missingPlayersEnabled() { return true; }
{
return true; @ConfigItem(
} keyName = "currentPlayers",
name = "Current CC Players",
@ConfigItem( description = "Adds a button to the PvP Tools panel that opens a window showing which CC members currently at" +
keyName = "missingPlayers", " the players location",
name = "Missing CC Players", position = 15
description = "Adds a button to the PvP Tools panel that opens a window showing which CC members are not at" + )
" the current players location", default boolean currentPlayersEnabled()
position = 14 {
) return true;
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; package net.runelite.client.plugins.wildernesslocations;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Player;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldArea; import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.wildernesslocations.WildernessLocationsOverlay; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.WildernessLocation; import net.runelite.client.util.WildernessLocation;
@PluginDescriptor(name="PvP Wild Locations", @PluginDescriptor(
description="Indicates the players current location in the wild", name = "Wild Locations",
tags={"Wildy,", "Wilderness Location", "location", "loc", "pvp", "pklite"}, description = "Indicates the players current location in the wild",
type = PluginType.PVP tags = {"Wildy", "Wilderness Location", "location", "loc", "pvp", "pklite"},
type = PluginType.PVP
) )
public class WildernessLocationsPlugin extends Plugin
public class WildernessLocationsPlugin extends Plugin { {
@Inject
private Client client; @Inject
@Inject private Client client;
OverlayManager overlayManager;
@Inject @Inject
private WildernessLocationsOverlay overlay; OverlayManager overlayManager;
private final HashMap<WorldArea, String> wildLocs;
private boolean renderLocation; @Inject
private String locationString; private WildernessLocationsOverlay overlay = new WildernessLocationsOverlay(this.client, this);
private WorldPoint worldPoint;
private static int UPDATE_INTERVAL = 3; private final HashMap<WorldArea, String> wildLocs = getLocationMap();
@Getter
public WildernessLocationsPlugin() { private boolean renderLocation;
overlay = new WildernessLocationsOverlay(client, this); @Getter
wildLocs = WildernessLocationsPlugin.getLocationMap(); private String locationString = "";
locationString = ""; private WorldPoint worldPoint = null;
worldPoint = null;
}
@Override
@Override protected void startUp() throws Exception
protected void startUp() throws Exception { {
overlayManager.add(overlay); overlayManager.add(overlay);
} }
@Override @Override
protected void shutDown() throws Exception { protected void shutDown() throws Exception
overlayManager.add(overlay); {
} overlayManager.remove(overlay);
}
@Subscribe
public void onGameTick(GameTick event) { @Subscribe
if (UPDATE_INTERVAL > 0) { public void onGameTick(GameTick event)
--UPDATE_INTERVAL; {
return; renderLocation = client.getVar(Varbits.IN_WILDERNESS) == 1;
} if (renderLocation)
boolean bl = renderLocation = client.getVar(Varbits.IN_WILDERNESS) == 1; {
if (renderLocation) { if (client.getLocalPlayer().getWorldLocation() != worldPoint)
if (client.getLocalPlayer().getWorldLocation() != worldPoint) { {
locationString = location(); locationString = location();
worldPoint = client.getLocalPlayer().getWorldLocation(); worldPoint = client.getLocalPlayer().getWorldLocation();
} }
} else { }
worldPoint = null; else
locationString = ""; {
} worldPoint = null;
UPDATE_INTERVAL = 3; locationString = "";
} }
}
private String location() {
int dist = 10000;
String s = ""; private String location()
WorldArea closestArea = null; {
for (Map.Entry<WorldArea, String> entry : wildLocs.entrySet()) { int dist = 10000;
WorldArea worldArea = entry.getKey(); String s = "";
if (worldArea.toWorldPointList().contains(client.getLocalPlayer().getWorldLocation())) { WorldArea closestArea = null;
s = entry.getValue(); for (Map.Entry<WorldArea, String> entry : wildLocs.entrySet())
return s; {
} WorldArea worldArea = entry.getKey();
int distTo = worldArea.distanceTo(client.getLocalPlayer().getWorldLocation());
if (distTo >= dist) continue; if (worldArea.toWorldPointList().contains(client.getLocalPlayer().getWorldLocation()))
dist = distTo; {
closestArea = worldArea; s = entry.getValue();
} return s;
if (client.getLocalPlayer().getWorldLocation().getY() > ((WorldArea)Objects.requireNonNull(closestArea)).toWorldPoint().getY() + closestArea.getHeight()) { }
s = s + "N"; int distTo = worldArea.distanceTo(client.getLocalPlayer().getWorldLocation());
} if (distTo < dist)
if (client.getLocalPlayer().getWorldLocation().getY() < closestArea.toWorldPoint().getY()) { {
s = s + "S"; dist = distTo;
} closestArea = worldArea;
if (client.getLocalPlayer().getWorldLocation().getX() < closestArea.toWorldPoint().getX()) { }
s = s + "W"; }
} if (client.getLocalPlayer().getWorldLocation().getY() >
if (client.getLocalPlayer().getWorldLocation().getX() > closestArea.toWorldPoint().getX() + closestArea.getWidth()) { (Objects.requireNonNull(closestArea).toWorldPoint().getY() + closestArea.getHeight()))
s = s + "E"; {
} s = s + "N";
s = s + " of "; }
if ((s = s + wildLocs.get(closestArea)).startsWith(" of ")) { if (client.getLocalPlayer().getWorldLocation().getY() < closestArea.toWorldPoint().getY())
s = s.substring(3); {
} s = s + "S";
return s; }
} if (client.getLocalPlayer().getWorldLocation().getX() < closestArea.toWorldPoint().getX())
{
private static HashMap<WorldArea, String> getLocationMap() { s = s + "W";
HashMap<WorldArea, String> hashMap = new HashMap<WorldArea, String>(); }
Arrays.stream(WildernessLocation.values()).forEach(wildernessLocation -> hashMap.put(wildernessLocation.getWorldArea(), wildernessLocation.getName())); if (client.getLocalPlayer().getWorldLocation().getX() >
return hashMap; (closestArea.toWorldPoint().getX() + closestArea.getWidth()))
} {
s = s + "E";
public boolean isRenderLocation() { }
return renderLocation; s = s + " of ";
} s = s + wildLocs.get(closestArea);
if (s.startsWith(" of "))
public String getLocationString() { {
return locationString; 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;
}
} }