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
@Slf4j
public class BlackjackPlugin extends Plugin {
public class BlackjackPlugin extends Plugin
{
@Inject
Client client;
@@ -65,47 +66,60 @@ public class BlackjackPlugin extends Plugin {
private static long currentGameTick;
@Override
public void configure(Binder binder) {
public void configure(Binder binder)
{
}
@Override
protected void startUp() throws Exception {
protected void startUp() throws Exception
{
currentGameTick = 0;
}
@Override
protected void shutDown() throws Exception {
protected void shutDown() throws Exception
{
currentGameTick = 0;
}
@Subscribe
public void onGameTick(GameTick gameTick) {
public void onGameTick(GameTick gameTick)
{
currentGameTick++;
}
@Subscribe
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.")) {
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."))
{
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();
}
}
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) {
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
{
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;
if (quest.getState(client) == QuestState.FINISHED) {
if (currentGameTick < (timeSinceKnockout + 4)) {
if (quest.getState(client) == QuestState.FINISHED)
{
if (currentGameTick < (timeSinceKnockout + 4))
{
stripSpecificEntries("pickpocket");
}
if (currentGameTick < (timeSinceAggro + 4)) {
if (currentGameTick < (timeSinceAggro + 4))
{
stripSpecificEntries("pickpocket");
}
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[] newEntries = new MenuEntry[2];
for (MenuEntry currentEntry : currentEntires) {
if (currentEntry.getOption().toLowerCase().equals(exceptFor.toLowerCase())) {
for (MenuEntry currentEntry : currentEntires)
{
if (currentEntry.getOption().toLowerCase().equals(exceptFor.toLowerCase()))
{
newEntries[1] = currentEntry;
}
if (currentEntry.getOption().toLowerCase().equals("lure")) {
if (currentEntry.getOption().toLowerCase().equals("lure"))
{
newEntries[0] = currentEntry;
}
}
if (newEntries[0] != null && newEntries[1] != null) {
if (newEntries[0] != null && newEntries[1] != null)
{
client.setMenuEntries(newEntries);
}
}

View File

@@ -30,10 +30,9 @@ import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.Player;
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.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
@@ -49,10 +48,6 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
private final PlayerIndicatorsConfig config;
private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class,
"skull.png");
@Inject
private ItemManager itemManager;
@Inject
private Client client;
@Inject
private PlayerIndicatorsMinimapOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService)
@@ -98,12 +93,8 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
}
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 height = graphics.getFontMetrics().getHeight();
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.getY());
}
break;
default:
break;
}
}
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.Player;
import net.runelite.api.Point;
import net.runelite.api.SkullIcon;
import net.runelite.api.kit.KitType;
import net.runelite.client.game.ClanManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager;
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.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
@@ -62,12 +61,9 @@ public class PlayerIndicatorsOverlay extends Overlay
private final ClanManager clanManager;
private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class,
"skull.png");
PvpToolsPlugin pvpToolsPlugin;
@Inject
private Client client;
@Inject
private SpriteManager spriteManager;
@Inject
private PlayerIndicatorsPlugin playerIndicatorsPlugin;
@Inject
private ItemManager itemManager;
@@ -164,7 +160,7 @@ public class PlayerIndicatorsOverlay extends Overlay
}
}
String tag = "";
String tag;
String prefix = "tag_";
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)
{
long totalValue = 0;
int newValue = 0;
int newValue;
StringBuilder stringBuilder = new StringBuilder(" ");
for (KitType kitType : KitType.values())
{
ItemComposition itemComposition =
itemManager.getItemComposition(actor.getPlayerComposition().getEquipmentId(kitType));
if (itemComposition != null || itemComposition.getName() != null)
if (itemComposition != null && itemComposition.getName() != null)
{
totalValue = totalValue + itemComposition.getPrice();
}
@@ -204,7 +200,7 @@ public class PlayerIndicatorsOverlay extends Overlay
newValue = (int) (totalValue / 1000);
if (newValue != 0)
{
stringBuilder.append("(" + formatNumber(newValue) + "K)");
stringBuilder.append("(").append(formatNumber(newValue)).append("K)");
name = name + stringBuilder;
}
}
@@ -216,11 +212,9 @@ public class PlayerIndicatorsOverlay extends Overlay
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 height = graphics.getFontMetrics().getHeight();
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.getY());
}
break;
default:
break;
}
}
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
}

View File

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

View File

@@ -63,11 +63,6 @@ public class PlayerIndicatorsTileOverlay extends Overlay
Polygon objectClickbox = player.getConvexHull();
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.image.BufferedImage;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.ItemID;
import net.runelite.api.NPC;
import net.runelite.api.Point;
@@ -44,16 +43,14 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ShayzienInfirmaryOverlay extends Overlay
{
private final ShayzienInfirmaryPlugin plugin;
private final Client client;
private BufferedImage medPackImage;
@Inject
public ShayzienInfirmaryOverlay(ShayzienInfirmaryPlugin plugin, Client client, ItemManager itemManager)
public ShayzienInfirmaryOverlay(ShayzienInfirmaryPlugin plugin, ItemManager itemManager)
{
setPosition(OverlayPosition.DYNAMIC);
this.plugin = plugin;
this.client = client;
medPackImage = itemManager.getImage(ItemID.SHAYZIEN_MEDPACK);
}

View File

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