Refactor WarIndicators

This commit is contained in:
Scott Burns
2019-05-16 01:20:46 +02:00
parent 03f2a76b9c
commit 65074d0447
4 changed files with 78 additions and 104 deletions

View File

@@ -34,10 +34,10 @@ import net.runelite.client.config.ConfigItem;
public interface WarIndicatorConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "highLightCallers",
name = "Highlight Callers",
description = "Highlight listed caller(s)"
position = 0,
keyName = "highLightCallers",
name = "Highlight Callers",
description = "Highlight listed caller(s)"
)
default boolean highLightCallers()
{
@@ -45,10 +45,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 1,
keyName = "callerColor",
name = "Caller(s) Color",
description = "Color to highlight caller's name"
position = 1,
keyName = "callerColor",
name = "Caller(s) Color",
description = "Color to highlight caller's name"
)
default Color getCallerColor()
{
@@ -56,10 +56,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 2,
keyName = "callerMinimap",
name = "Callers on Minimap",
description = "Show your caller(s) on the minimap"
position = 2,
keyName = "callerMinimap",
name = "Callers on Minimap",
description = "Show your caller(s) on the minimap"
)
default boolean callerMinimap()
{
@@ -68,10 +68,10 @@ public interface WarIndicatorConfig extends Config
@ConfigItem(
position = 3,
keyName = "callerTile",
name = "Show Caller's Tile",
description = "Show the tile your target is standing on"
position = 3,
keyName = "callerTile",
name = "Show Caller's Tile",
description = "Show the tile your target is standing on"
)
default boolean callerTile()
{
@@ -79,10 +79,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 4,
keyName = "activeCallers",
name = "Callers",
description = "Adds a user to your caller list. Format: (caller), (caller)"
position = 4,
keyName = "activeCallers",
name = "Callers",
description = "Adds a user to your caller list. Format: (caller), (caller)"
)
default String getActiveCallers()
{
@@ -90,19 +90,19 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 5,
keyName = "activeCallers",
name = "",
description = ""
position = 5,
keyName = "activeCallers",
name = "",
description = ""
)
void setActiveCallers(String key);
@ConfigItem(
position = 6,
keyName = "highlightSnipes",
name = "Highlight Targets",
description = "Highlight listed target(s)"
position = 6,
keyName = "highlightSnipes",
name = "Highlight Targets",
description = "Highlight listed target(s)"
)
default boolean highlightSnipes()
{
@@ -110,10 +110,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 7,
keyName = "snipeColor",
name = "Target(s) Color",
description = "Color to highlight target name"
position = 7,
keyName = "snipeColor",
name = "Target(s) Color",
description = "Color to highlight target name"
)
default Color getSnipeColor()
{
@@ -121,10 +121,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 8,
keyName = "snipeMinimap",
name = "Targets on Minimap",
description = "Show your target on the minimap"
position = 8,
keyName = "snipeMinimap",
name = "Targets on Minimap",
description = "Show your target on the minimap"
)
default boolean snipeMinimap()
{
@@ -132,10 +132,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 9,
keyName = "snipeTile",
name = "Show Target's Tile",
description = "Show the tile your target is standing on"
position = 9,
keyName = "snipeTile",
name = "Show Target's Tile",
description = "Show the tile your target is standing on"
)
default boolean snipeTile()
{
@@ -143,10 +143,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 10,
keyName = "targetedSnipes",
name = "Targets",
description = "Adds a user to your snipe list. Format: (target), (target)"
position = 10,
keyName = "targetedSnipes",
name = "Targets",
description = "Adds a user to your snipe list. Format: (target), (target)"
)
default String getTargetedSnipes()
{
@@ -154,11 +154,10 @@ public interface WarIndicatorConfig extends Config
}
@ConfigItem(
position = 11,
keyName = "targetedSnipes",
name = "",
description = ""
position = 11,
keyName = "targetedSnipes",
name = "",
description = ""
)
void setTargetedSnipe(String key);
}

View File

@@ -30,7 +30,6 @@ import java.awt.Graphics2D;
import java.awt.Polygon;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.ArrayUtils;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.client.ui.overlay.Overlay;
@@ -38,6 +37,7 @@ import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.OverlayUtil;
import org.apache.commons.lang3.ArrayUtils;
@Singleton
public class WarIndicatorOverlay extends Overlay

View File

@@ -24,43 +24,28 @@
*/
package net.runelite.client.plugins.warindicators;
import com.google.common.collect.Sets;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.awt.Color;
import java.util.Collection;
import javax.inject.Inject;
import net.runelite.client.plugins.PluginType;
import org.apache.commons.lang3.ArrayUtils;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.FOLLOW;
import static net.runelite.api.MenuAction.ITEM_USE_ON_PLAYER;
import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION;
import static net.runelite.api.MenuAction.PLAYER_FOURTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SECOND_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER;
import static net.runelite.api.MenuAction.TRADE;
import static net.runelite.api.MenuAction.*;
import net.runelite.api.MenuEntry;
import net.runelite.api.Player;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.overlay.OverlayManager;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
name = "War calling indicators",
description = "War War War.",
tags = {"skill", "total", "max", "PVP"},
type = PluginType.PVP,
enabledByDefault = false
name = "War calling indicators",
description = "War War War.",
tags = {"skill", "total", "max", "PVP"},
type = PluginType.PVP,
enabledByDefault = false
)
public class WarIndicatorPlugin extends Plugin
{
@@ -85,19 +70,19 @@ public class WarIndicatorPlugin extends Plugin
return configManager.getConfig(WarIndicatorConfig.class);
}
@Override
protected void startUp() throws Exception
{
overlayManager.add(warIndicatorOverlay);
overlayManager.add(warIndicatorMiniMapOverlay);
}
@Override
protected void startUp() throws Exception
{
overlayManager.add(warIndicatorOverlay);
overlayManager.add(warIndicatorMiniMapOverlay);
}
@Override
protected void shutDown() throws Exception
{
overlayManager.remove(warIndicatorOverlay);
overlayManager.remove(warIndicatorMiniMapOverlay);
}
@Override
protected void shutDown() throws Exception
{
overlayManager.remove(warIndicatorOverlay);
overlayManager.remove(warIndicatorMiniMapOverlay);
}
@Subscribe
public void onMenuEntryAdd(MenuEntryAdded menuEntryAdded)

View File

@@ -24,12 +24,12 @@
*/
package net.runelite.client.plugins.warindicators;
import net.runelite.api.Client;
import net.runelite.api.Player;
import java.awt.Color;
import java.util.function.BiConsumer;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.awt.*;
import java.util.function.BiConsumer;
import net.runelite.api.Client;
import net.runelite.api.Player;
@Singleton
public class WarIndicatorService
@@ -62,14 +62,9 @@ public class WarIndicatorService
String[] targets = config.getTargetedSnipes().split(", ");
if (targets == null)
for (String target : targets)
{
return;
}
for (int i = 0; i < targets.length; i++)
{
if (player.getName().equalsIgnoreCase(targets[i]))
if (player.getName().equalsIgnoreCase(target))
{
consumer.accept(player, config.getSnipeColor());
}
@@ -88,14 +83,9 @@ public class WarIndicatorService
String[] callers = config.getActiveCallers().split(", ");
if (callers == null)
for (String caller : callers)
{
return;
}
for (int i = 0; i < callers.length; i++)
{
if (player.getName().equalsIgnoreCase(callers[i]))
if (player.getName().equalsIgnoreCase(caller))
{
consumer.accept(player, config.getCallerColor());
}