checkstyle - blackjack/player indicators/shayzien infirmary

This commit is contained in:
Lucas
2019-05-17 03:33:05 +02:00
parent 60e92469dd
commit 34b16cf300
8 changed files with 354 additions and 377 deletions

View File

@@ -53,7 +53,8 @@ import net.runelite.client.plugins.PluginType;
) )
@Singleton @Singleton
@Slf4j @Slf4j
public class BlackjackPlugin extends Plugin { public class BlackjackPlugin extends Plugin
{
@Inject @Inject
Client client; Client client;
@@ -65,47 +66,60 @@ public class BlackjackPlugin extends Plugin {
private static long currentGameTick; private static long currentGameTick;
@Override @Override
public void configure(Binder binder) { public void configure(Binder binder)
{
} }
@Override @Override
protected void startUp() throws Exception { protected void startUp() throws Exception
{
currentGameTick = 0; currentGameTick = 0;
} }
@Override @Override
protected void shutDown() throws Exception { protected void shutDown() throws Exception
{
currentGameTick = 0; currentGameTick = 0;
} }
@Subscribe @Subscribe
public void onGameTick(GameTick gameTick) { public void onGameTick(GameTick gameTick)
{
currentGameTick++; currentGameTick++;
} }
@Subscribe @Subscribe
public void onChatMessage(ChatMessage chatMessage) { public void onChatMessage(ChatMessage chatMessage)
if (chatMessage.getType() == ChatMessageType.SPAM) { {
if (chatMessage.getMessage().equals("You smack the bandit over the head and render them unconscious.")) { if (chatMessage.getType() == ChatMessageType.SPAM)
{
if (chatMessage.getMessage().equals("You smack the bandit over the head and render them unconscious."))
{
timeSinceKnockout = getCurrentGameTick(); timeSinceKnockout = getCurrentGameTick();
} }
if (chatMessage.getMessage().equals("Your blow only glances off the bandit's head.")) { if (chatMessage.getMessage().equals("Your blow only glances off the bandit's head."))
{
timeSinceAggro = getCurrentGameTick(); timeSinceAggro = getCurrentGameTick();
} }
} }
} }
@Subscribe @Subscribe
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
{
String target = menuEntryAdded.getTarget().toLowerCase(); String target = menuEntryAdded.getTarget().toLowerCase();
if ((target.contains("bandit") | target.contains("menaphite thug"))) { if ((target.contains("bandit") | target.contains("menaphite thug")))
{
Quest quest = Quest.THE_FEUD; Quest quest = Quest.THE_FEUD;
if (quest.getState(client) == QuestState.FINISHED) { if (quest.getState(client) == QuestState.FINISHED)
if (currentGameTick < (timeSinceKnockout + 4)) { {
if (currentGameTick < (timeSinceKnockout + 4))
{
stripSpecificEntries("pickpocket"); stripSpecificEntries("pickpocket");
} }
if (currentGameTick < (timeSinceAggro + 4)) { if (currentGameTick < (timeSinceAggro + 4))
{
stripSpecificEntries("pickpocket"); stripSpecificEntries("pickpocket");
} }
stripSpecificEntries("knock-out"); stripSpecificEntries("knock-out");
@@ -113,20 +127,25 @@ public class BlackjackPlugin extends Plugin {
} }
} }
private void stripSpecificEntries(String exceptFor) { private void stripSpecificEntries(String exceptFor)
{
MenuEntry[] currentEntires = client.getMenuEntries(); MenuEntry[] currentEntires = client.getMenuEntries();
MenuEntry[] newEntries = new MenuEntry[2]; MenuEntry[] newEntries = new MenuEntry[2];
for (MenuEntry currentEntry : currentEntires) { for (MenuEntry currentEntry : currentEntires)
if (currentEntry.getOption().toLowerCase().equals(exceptFor.toLowerCase())) { {
if (currentEntry.getOption().toLowerCase().equals(exceptFor.toLowerCase()))
{
newEntries[1] = currentEntry; newEntries[1] = currentEntry;
} }
if (currentEntry.getOption().toLowerCase().equals("lure")) { if (currentEntry.getOption().toLowerCase().equals("lure"))
{
newEntries[0] = currentEntry; newEntries[0] = currentEntry;
} }
} }
if (newEntries[0] != null && newEntries[1] != null) { if (newEntries[0] != null && newEntries[1] != null)
{
client.setMenuEntries(newEntries); client.setMenuEntries(newEntries);
} }
} }

View File

@@ -30,10 +30,9 @@ import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.client.game.ItemManager; import net.runelite.api.SkullIcon;
import net.runelite.client.plugins.friendtagging.FriendTaggingPlugin; import net.runelite.client.plugins.friendtagging.FriendTaggingPlugin;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
@@ -49,10 +48,6 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
private final PlayerIndicatorsConfig config; private final PlayerIndicatorsConfig config;
private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class,
"skull.png"); "skull.png");
@Inject
private ItemManager itemManager;
@Inject
private Client client;
@Inject @Inject
private PlayerIndicatorsMinimapOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService) private PlayerIndicatorsMinimapOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService)
@@ -98,12 +93,8 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
} }
if (config.drawMinimapNames()) if (config.drawMinimapNames())
{ {
if (actor.getSkullIcon() != null && config.playerSkull()) if (actor.getSkullIcon() != null && config.playerSkull() && actor.getSkullIcon() == SkullIcon.SKULL)
{ {
switch (actor.getSkullIcon())
{
case SKULL:
int width = graphics.getFontMetrics().stringWidth(name); int width = graphics.getFontMetrics().stringWidth(name);
int height = graphics.getFontMetrics().getHeight(); int height = graphics.getFontMetrics().getHeight();
if (config.skullLocation().equals(PlayerIndicatorsPlugin.minimapSkullLocations.AFTER_NAME)) if (config.skullLocation().equals(PlayerIndicatorsPlugin.minimapSkullLocations.AFTER_NAME))
@@ -120,10 +111,6 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(), minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(),
minimapLocation.getY()); minimapLocation.getY());
} }
break;
default:
break;
}
} }
OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
} }

View File

@@ -36,12 +36,11 @@ import net.runelite.api.Client;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.SkullIcon;
import net.runelite.api.kit.KitType; import net.runelite.api.kit.KitType;
import net.runelite.client.game.ClanManager; import net.runelite.client.game.ClanManager;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.plugins.friendtagging.FriendTaggingPlugin; import net.runelite.client.plugins.friendtagging.FriendTaggingPlugin;
import net.runelite.client.plugins.pvptools.PvpToolsPlugin;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayPriority;
@@ -62,12 +61,9 @@ public class PlayerIndicatorsOverlay extends Overlay
private final ClanManager clanManager; private final ClanManager clanManager;
private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class,
"skull.png"); "skull.png");
PvpToolsPlugin pvpToolsPlugin;
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private SpriteManager spriteManager;
@Inject
private PlayerIndicatorsPlugin playerIndicatorsPlugin; private PlayerIndicatorsPlugin playerIndicatorsPlugin;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@@ -164,7 +160,7 @@ public class PlayerIndicatorsOverlay extends Overlay
} }
} }
String tag = ""; String tag;
String prefix = "tag_"; String prefix = "tag_";
if (FriendTaggingPlugin.taggedFriends.containsKey(prefix + name.trim().toLowerCase())) if (FriendTaggingPlugin.taggedFriends.containsKey(prefix + name.trim().toLowerCase()))
{ {
@@ -190,13 +186,13 @@ public class PlayerIndicatorsOverlay extends Overlay
if (config.targetRisk() && PvPUtil.isAttackable(client, actor) && actor.getPlayerComposition() != null) if (config.targetRisk() && PvPUtil.isAttackable(client, actor) && actor.getPlayerComposition() != null)
{ {
long totalValue = 0; long totalValue = 0;
int newValue = 0; int newValue;
StringBuilder stringBuilder = new StringBuilder(" "); StringBuilder stringBuilder = new StringBuilder(" ");
for (KitType kitType : KitType.values()) for (KitType kitType : KitType.values())
{ {
ItemComposition itemComposition = ItemComposition itemComposition =
itemManager.getItemComposition(actor.getPlayerComposition().getEquipmentId(kitType)); itemManager.getItemComposition(actor.getPlayerComposition().getEquipmentId(kitType));
if (itemComposition != null || itemComposition.getName() != null) if (itemComposition != null && itemComposition.getName() != null)
{ {
totalValue = totalValue + itemComposition.getPrice(); totalValue = totalValue + itemComposition.getPrice();
} }
@@ -204,7 +200,7 @@ public class PlayerIndicatorsOverlay extends Overlay
newValue = (int) (totalValue / 1000); newValue = (int) (totalValue / 1000);
if (newValue != 0) if (newValue != 0)
{ {
stringBuilder.append("(" + formatNumber(newValue) + "K)"); stringBuilder.append("(").append(formatNumber(newValue)).append("K)");
name = name + stringBuilder; name = name + stringBuilder;
} }
} }
@@ -216,11 +212,9 @@ public class PlayerIndicatorsOverlay extends Overlay
name = name + " cGLORY"; name = name + " cGLORY";
} }
} }
if (actor.getSkullIcon() != null && config.playerSkull())
if (actor.getSkullIcon() != null && config.playerSkull() && actor.getSkullIcon() == SkullIcon.SKULL)
{ {
switch (actor.getSkullIcon())
{
case SKULL:
int width = graphics.getFontMetrics().stringWidth(name); int width = graphics.getFontMetrics().stringWidth(name);
int height = graphics.getFontMetrics().getHeight(); int height = graphics.getFontMetrics().getHeight();
if (config.skullLocation().equals(PlayerIndicatorsPlugin.minimapSkullLocations.AFTER_NAME)) if (config.skullLocation().equals(PlayerIndicatorsPlugin.minimapSkullLocations.AFTER_NAME))
@@ -237,10 +231,6 @@ public class PlayerIndicatorsOverlay extends Overlay
textLocation = new Point(textLocation.getX() + skullIcon.getWidth(), textLocation = new Point(textLocation.getX() + skullIcon.getWidth(),
textLocation.getY()); textLocation.getY());
} }
break;
default:
break;
}
} }
OverlayUtil.renderTextLocation(graphics, textLocation, name, color); OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
} }

View File

@@ -31,15 +31,12 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.ClanMember; import net.runelite.api.ClanMember;
import net.runelite.api.ClanMemberRank; import net.runelite.api.ClanMemberRank;
import static net.runelite.api.ClanMemberRank.UNRANKED; import static net.runelite.api.ClanMemberRank.UNRANKED;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.MenuAction.*; import static net.runelite.api.MenuAction.*;
import net.runelite.api.HeadIcon;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.events.ClanMemberJoined; import net.runelite.api.events.ClanMemberJoined;
@@ -128,7 +125,7 @@ public class PlayerIndicatorsPlugin extends Plugin
{ {
for (String name:callers) for (String name:callers)
{ {
Actor pile = null; Actor pile;
String finalName = name.toLowerCase().replace("_", " "); String finalName = name.toLowerCase().replace("_", " ");
if (p.getName().toLowerCase().replace("_", " ").equals(finalName)) if (p.getName().toLowerCase().replace("_", " ").equals(finalName))
{ {
@@ -160,7 +157,7 @@ public class PlayerIndicatorsPlugin extends Plugin
getCallerList(); getCallerList();
} }
public void getCallerList() private void getCallerList()
{ {
callers.clear(); callers.clear();
if (config.useClanchatRanks() && client.getClanMembers() != null) if (config.useClanchatRanks() && client.getClanMembers() != null)
@@ -187,7 +184,7 @@ public class PlayerIndicatorsPlugin extends Plugin
pileList = Arrays.asList(new String[callers.size()]); pileList = Arrays.asList(new String[callers.size()]);
} }
public boolean isCaller(Player player) boolean isCaller(Player player)
{ {
if (callers != null) if (callers != null)
{ {
@@ -200,18 +197,15 @@ public class PlayerIndicatorsPlugin extends Plugin
} }
} }
} }
else {return false;}
return false; return false;
} }
public boolean isPile(Player player) boolean isPile(Player player)
{ {
if (Objects.nonNull(pileList) && pileList.size() > 0) if (Objects.nonNull(pileList) && pileList.size() > 0)
{ {
if (pileList.contains(player.getName())) return pileList.contains(player.getName());
{
return true;
}
} }
return false; return false;
} }
@@ -359,7 +353,7 @@ public class PlayerIndicatorsPlugin extends Plugin
} }
} }
public static enum minimapSkullLocations public enum minimapSkullLocations
{ {
BEFORE_NAME, BEFORE_NAME,
AFTER_NAME AFTER_NAME

View File

@@ -63,11 +63,6 @@ public class PlayerIndicatorsTileOverlay extends Overlay
Polygon objectClickbox = player.getConvexHull(); Polygon objectClickbox = player.getConvexHull();
renderPoly(graphics, config.pileColor(), objectClickbox); renderPoly(graphics, config.pileColor(), objectClickbox);
if (objectClickbox != null)
{
}
} }
}); });
} }

View File

@@ -32,7 +32,6 @@ import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.Point; import net.runelite.api.Point;
@@ -44,16 +43,14 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ShayzienInfirmaryOverlay extends Overlay public class ShayzienInfirmaryOverlay extends Overlay
{ {
private final ShayzienInfirmaryPlugin plugin; private final ShayzienInfirmaryPlugin plugin;
private final Client client;
private BufferedImage medPackImage; private BufferedImage medPackImage;
@Inject @Inject
public ShayzienInfirmaryOverlay(ShayzienInfirmaryPlugin plugin, Client client, ItemManager itemManager) public ShayzienInfirmaryOverlay(ShayzienInfirmaryPlugin plugin, ItemManager itemManager)
{ {
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
this.plugin = plugin; this.plugin = plugin;
this.client = client;
medPackImage = itemManager.getImage(ItemID.SHAYZIEN_MEDPACK); medPackImage = itemManager.getImage(ItemID.SHAYZIEN_MEDPACK);
} }

View File

@@ -85,7 +85,7 @@ public class ShayzienInfirmaryPlugin extends Plugin
@Subscribe @Subscribe
public void onGameTick(GameTick event) public void onGameTick(GameTick event)
{ {
if(!isAtInfirmary()) if (!isAtInfirmary())
{ {
return; return;
} }
@@ -101,22 +101,17 @@ public class ShayzienInfirmaryPlugin extends Plugin
} }
} }
public boolean isSoldierId(int npcId) private boolean isSoldierId(int npcId)
{ {
return (npcId >= 6826 && npcId <= 6857); return (npcId >= 6826 && npcId <= 6857);
} }
public boolean isUnhealedSoldierId(int npcId) private boolean isUnhealedSoldierId(int npcId)
{ {
return (isSoldierId(npcId) && npcId % 2 == 0); return (isSoldierId(npcId) && npcId % 2 == 0);
} }
public boolean isHealedSoldierId(int npcId) boolean isAtInfirmary()
{
return (isSoldierId(npcId) && npcId % 2 == 1);
}
public boolean isAtInfirmary()
{ {
return client.getLocalPlayer().getWorldLocation().getRegionID() == 6200; return client.getLocalPlayer().getWorldLocation().getRegionID() == 6200;
} }