Merge pull request #915 from sdburns1998/vijfeuroopjemuil

runelite-client: code cleanup (and clue scroll fix)
This commit is contained in:
Tyler Bochard
2019-07-07 18:17:32 -07:00
committed by GitHub
299 changed files with 1792 additions and 2287 deletions
@@ -313,4 +313,11 @@ public final class AnimationID
public static final int DAG_REX = 2853; public static final int DAG_REX = 2853;
public static final int DAG_PRIME = 2854; public static final int DAG_PRIME = 2854;
public static final int DAG_SUPREME = 2855; public static final int DAG_SUPREME = 2855;
// Lizardman shaman
public static final int LIZARDMAN_SHAMAN_SPAWN = 2855;
// Combat counter
public static final int BARRAGE_ANIMATION = 1979;
public static final int CHIN_ANIMATION = 7618;
} }
@@ -205,4 +205,9 @@ public final class ScriptID
* Send a public message * Send a public message
*/ */
public static final int PUBLICMSG = 13337; public static final int PUBLICMSG = 13337;
/**
* TExt typed in the chatbox
*/
public static final int CHATBOX_TEXT = 96;
} }
@@ -151,6 +151,7 @@ public class WidgetID
public static final int BEGINNER_CLUE_MAP_WIZARDS_TOWER = 356; public static final int BEGINNER_CLUE_MAP_WIZARDS_TOWER = 356;
public static final int SEED_BOX_GROUP_ID = 128; public static final int SEED_BOX_GROUP_ID = 128;
public static final int ITEMS_KEPT_ON_DEATH_GROUP_ID = 4; public static final int ITEMS_KEPT_ON_DEATH_GROUP_ID = 4;
public static final int TRADING_SCREEN = 335;
static class WorldMap static class WorldMap
{ {
@@ -53,10 +53,7 @@ public class ConfigDescriptor
Collection<ConfigItemDescriptor> allItems = new ArrayList<>(); Collection<ConfigItemDescriptor> allItems = new ArrayList<>();
for (ConfigItemsGroup g : itemGroups) for (ConfigItemsGroup g : itemGroups)
{ {
for (ConfigItemDescriptor item : g.getItems()) allItems.addAll(g.getItems());
{
allItems.add(item);
}
} }
return allItems; return allItems;
} }
@@ -81,7 +81,6 @@ public class ConfigManager
@Inject @Inject
EventBus eventBus; EventBus eventBus;
private final ScheduledExecutorService executor;
private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this); private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this);
private final Properties properties = new Properties(); private final Properties properties = new Properties();
private final Map<String, Object> configObjectCache = new HashMap<>(); private final Map<String, Object> configObjectCache = new HashMap<>();
@@ -90,9 +89,8 @@ public class ConfigManager
@Inject @Inject
public ConfigManager(ScheduledExecutorService scheduledExecutorService) public ConfigManager(ScheduledExecutorService scheduledExecutorService)
{ {
this.executor = scheduledExecutorService;
executor.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS); scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
} }
public final void switchSession() public final void switchSession()
@@ -245,12 +243,10 @@ public class ConfigManager
throw new RuntimeException("Non-public configuration classes can't have default methods invoked"); throw new RuntimeException("Non-public configuration classes can't have default methods invoked");
} }
T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[]
{ {
clazz clazz
}, handler); }, handler);
return t;
} }
public List<String> getConfigurationKeys(String prefix) public List<String> getConfigurationKeys(String prefix)
@@ -60,7 +60,7 @@ public class Keybind
private final int keyCode; private final int keyCode;
private final int modifiers; private final int modifiers;
protected Keybind(int keyCode, int modifiers, boolean ignoreModifiers) Keybind(int keyCode, int modifiers, boolean ignoreModifiers)
{ {
modifiers &= KEYBOARD_MODIFIER_MASK; modifiers &= KEYBOARD_MODIFIER_MASK;
@@ -108,7 +108,7 @@ public class Keybind
return matches(e, false); return matches(e, false);
} }
protected boolean matches(KeyEvent e, boolean ignoreModifiers) boolean matches(KeyEvent e, boolean ignoreModifiers)
{ {
if (NOT_SET.equals(this)) if (NOT_SET.equals(this))
{ {
@@ -177,7 +177,7 @@ public class Keybind
return mod; return mod;
} }
public static String getModifiersExText(int modifiers) private static String getModifiersExText(int modifiers)
{ {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
if ((modifiers & InputEvent.META_DOWN_MASK) != 0) if ((modifiers & InputEvent.META_DOWN_MASK) != 0)
@@ -124,10 +124,6 @@ public class DiaryRequirementsPlugin extends Plugin
} }
Map<String, String> skillRequirements = buildRequirements(requirements.getRequirements()); Map<String, String> skillRequirements = buildRequirements(requirements.getRequirements());
if (skillRequirements == null)
{
return;
}
int offset = 0; int offset = 0;
String taskBuffer = ""; String taskBuffer = "";
@@ -39,9 +39,9 @@ class AmmoCounter extends Counter
{ {
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private int itemID; private int itemID;
private String name; private final String name;
private int total; private final int total;
private Instant time; private final Instant time;
private BigDecimal ammoPerHour; private BigDecimal ammoPerHour;
AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image) AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image)
@@ -144,7 +144,7 @@ public class AntiDragPlugin extends Plugin
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.alwaysOn = config.alwaysOn(); this.alwaysOn = config.alwaysOn();
this.keybind = config.keybind(); this.keybind = config.keybind();
@@ -160,15 +160,12 @@ public class AntiDragPlugin extends Plugin
@Subscribe @Subscribe
public void onFocusChanged(FocusChanged focusChanged) public void onFocusChanged(FocusChanged focusChanged)
{ {
if (!this.alwaysOn) if (!this.alwaysOn && !focusChanged.isFocused() && this.reqfocus)
{
if (!focusChanged.isFocused() && this.reqfocus)
{ {
client.setInventoryDragDelay(DEFAULT_DELAY); client.setInventoryDragDelay(DEFAULT_DELAY);
overlayManager.remove(overlay); overlayManager.remove(overlay);
} }
} }
}
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> this.key) private final HotkeyListener hotkeyListener = new HotkeyListener(() -> this.key)
{ {
@@ -157,14 +157,12 @@ public class AoeWarningOverlay extends Overlay
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), outlineAlpha), true)); graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), outlineAlpha), true));
graphics.drawPolygon(tilePoly); graphics.drawPolygon(tilePoly);
} }
if (plugin.isTickTimers()) if (plugin.isTickTimers() && tickProgress >= 0)
{
if (tickProgress >= 0)
{ {
OverlayUtil.renderTextLocation(graphics, Integer.toString(tickProgress), plugin.getTextSize(), OverlayUtil.renderTextLocation(graphics, Integer.toString(tickProgress), plugin.getTextSize(),
plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0); plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0);
} }
}
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true)); graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true));
graphics.fillPolygon(tilePoly); graphics.fillPolygon(tilePoly);
} }
@@ -450,7 +450,7 @@ public class AoeWarningPlugin extends Plugin
return false; return false;
} }
public void updateConfig() private void updateConfig()
{ {
this.aoeNotifyAll = config.aoeNotifyAll(); this.aoeNotifyAll = config.aoeNotifyAll();
this.overlayColor = config.overlayColor(); this.overlayColor = config.overlayColor();
@@ -269,7 +269,7 @@ public class AttackStylesPlugin extends Plugin
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.alwaysShowStyle = config.alwaysShowStyle(); this.alwaysShowStyle = config.alwaysShowStyle();
this.warnForDefence = config.warnForDefence(); this.warnForDefence = config.warnForDefence();
@@ -320,10 +320,10 @@ public class AttackStylesPlugin extends Plugin
{ {
if (warnedSkills.contains(skill)) if (warnedSkills.contains(skill))
{ {
if (weaponSwitch) // if (weaponSwitch)
{ // {
// TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change // // TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change
} // }
warnedSkillSelected = true; warnedSkillSelected = true;
break; break;
} }
@@ -203,7 +203,7 @@ public class BankPlugin extends Plugin
updateConfig(); updateConfig();
} }
public void updateConfig() private void updateConfig()
{ {
this.showGE = config.showGE(); this.showGE = config.showGE();
this.showHA = config.showHA(); this.showHA = config.showHA();
@@ -246,10 +246,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
intStack[intStackSize - 1] = 0; intStack[intStackSize - 1] = 0;
break; break;
case "hideLine": case "hideLine":
// hide the widget for the line separator
intStack[intStackSize - 1] = 1;
break;
case "hideTabText": case "hideTabText":
// hide the widget for the line separator
// hide the widget for the "Tab x" text // hide the widget for the "Tab x" text
intStack[intStackSize - 1] = 1; intStack[intStackSize - 1] = 1;
break; break;
@@ -66,7 +66,7 @@ public class TagManager
this.clueScrollService = clueScrollService; this.clueScrollService = clueScrollService;
} }
String getTagString(int itemId, boolean variation) private String getTagString(int itemId, boolean variation)
{ {
itemId = getItemId(itemId, variation); itemId = getItemId(itemId, variation);
@@ -53,8 +53,8 @@ import net.runelite.api.Client;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.api.InventoryID; import net.runelite.api.InventoryID;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.Point; import net.runelite.api.Point;
@@ -579,12 +579,15 @@ public class TabInterface
if (event.getOption().startsWith(CHANGE_ICON + " (")) if (event.getOption().startsWith(CHANGE_ICON + " ("))
{ {
ItemDefinition item = getItem(event.getActionParam0()); ItemDefinition item = getItem(event.getActionParam0());
if (item != null)
{
int itemId = itemManager.canonicalize(item.getId()); int itemId = itemManager.canonicalize(item.getId());
iconToSet.setIconItemId(itemId); iconToSet.setIconItemId(itemId);
iconToSet.getIcon().setItemId(itemId); iconToSet.getIcon().setItemId(itemId);
tabManager.setIcon(iconToSet.getTag(), itemId + ""); tabManager.setIcon(iconToSet.getTag(), itemId + "");
event.consume(); event.consume();
} }
}
// Reset icon selection even when we do not clicked item with icon // Reset icon selection even when we do not clicked item with icon
iconToSet = null; iconToSet = null;
@@ -613,10 +616,14 @@ public class TabInterface
// Add "remove" menu entry to all items in bank while tab is selected // Add "remove" menu entry to all items in bank while tab is selected
event.consume(); event.consume();
final ItemDefinition item = getItem(event.getActionParam0()); final ItemDefinition item = getItem(event.getActionParam0());
final int itemId = item.getId(); final int itemId;
if (item != null)
{
itemId = item.getId();
tagManager.removeTag(itemId, activeTab.getTag()); tagManager.removeTag(itemId, activeTab.getTag());
bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true); bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true);
} }
}
else if (event.getMenuAction() == MenuAction.RUNELITE else if (event.getMenuAction() == MenuAction.RUNELITE
&& ((event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getOption().equals(TAG_INVENTORY)) && ((event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getOption().equals(TAG_INVENTORY))
|| (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId() && event.getOption().equals(TAG_GEAR)))) || (event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId() && event.getOption().equals(TAG_GEAR))))
@@ -669,17 +676,13 @@ public class TabInterface
updateTabIfActive(Lists.newArrayList(Text.standardize(draggedOn.getName()))); updateTabIfActive(Lists.newArrayList(Text.standardize(draggedOn.getName())));
} }
} }
else if (parent.getId() == draggedOn.getId() && parent.getId() == draggedWidget.getId()) else if (parent.getId() == draggedOn.getId() && parent.getId() == draggedWidget.getId() && !Strings.isNullOrEmpty(draggedOn.getName()))
{
// Reorder tag tabs
if (!Strings.isNullOrEmpty(draggedOn.getName()))
{ {
tabManager.move(draggedWidget.getName(), draggedOn.getName()); tabManager.move(draggedWidget.getName(), draggedOn.getName());
tabManager.save(); tabManager.save();
updateTabs(); updateTabs();
} }
} }
}
else if (draggedWidget.getItemId() > 0) else if (draggedWidget.getItemId() > 0)
{ {
MenuEntry[] entries = client.getMenuEntries(); MenuEntry[] entries = client.getMenuEntries();
@@ -1010,10 +1013,19 @@ public class TabInterface
private ItemDefinition getItem(int idx) private ItemDefinition getItem(int idx)
{ {
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK); ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
Item item = bankContainer.getItems()[idx]; Item item = null;
if (bankContainer != null)
{
item = bankContainer.getItems()[idx];
}
if (item != null)
{
return itemManager.getItemDefinition(item.getId()); return itemManager.getItemDefinition(item.getId());
} }
return null;
}
private void openTag(final String tag) private void openTag(final String tag)
{ {
bankSearch.search(InputType.SEARCH, TAG_SEARCH + tag, true); bankSearch.search(InputType.SEARCH, TAG_SEARCH + tag, true);
@@ -26,10 +26,14 @@
*/ */
package net.runelite.client.plugins.banlist; package net.runelite.client.plugins.banlist;
import com.google.common.base.Splitter;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -42,6 +46,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.WidgetHiddenChanged; import net.runelite.api.events.WidgetHiddenChanged;
import net.runelite.api.events.WidgetLoaded; import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.TRADING_SCREEN;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatColorType;
@@ -84,10 +89,10 @@ public class BanListPlugin extends Plugin
@Inject @Inject
private ChatMessageManager chatMessageManager; private ChatMessageManager chatMessageManager;
private ArrayList<String> wdrScamArrayList = new ArrayList<>(); private final Set<String> wdrScamSet = new HashSet<>();
private ArrayList<String> wdrToxicArrayList = new ArrayList<>(); private final Set<String> wdrToxicSet = new HashSet<>();
private ArrayList<String> runeWatchArrayList = new ArrayList<>(); private final Set<String> runeWatchSet = new HashSet<>();
private ArrayList<String> manualBans = new ArrayList<>(); private final Set<String> manualBans = new HashSet<>();
@Provides @Provides
BanListConfig getConfig(ConfigManager configManager) BanListConfig getConfig(ConfigManager configManager)
@@ -105,38 +110,46 @@ public class BanListPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
manualBans.addAll(Text.fromCSV(config.getBannedPlayers())); List<String> bannedPlayers = Splitter
.on(",")
.trimResults()
.omitEmptyStrings()
.splitToList(config.getBannedPlayers());
manualBans.addAll(bannedPlayers);
fetchFromWebsites(); fetchFromWebsites();
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
wdrScamArrayList.clear(); wdrScamSet.clear();
wdrToxicArrayList.clear(); wdrToxicSet.clear();
runeWatchArrayList.clear(); runeWatchSet.clear();
manualBans.clear(); manualBans.clear();
} }
@Subscribe @Subscribe
public void onConfigChanged(ConfigChanged event) public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("banlist")) if (event.getGroup().equals("banlist") && event.getKey().equals("bannedPlayers"))
{ {
if (event.getKey().equals("bannedPlayers")) List<String> bannedPlayers = Splitter
.on(",")
.trimResults()
.omitEmptyStrings()
.splitToList(config.getBannedPlayers());
for (String bannedPlayer : bannedPlayers)
{ {
for (String manual : Text.fromCSV(config.getBannedPlayers())) if (!manualBans.contains(bannedPlayer))
{ {
if (!manualBans.contains(manual)) manualBans.add(Text.standardize(bannedPlayer));
{
manualBans.add(Text.standardize(manual));
}
} }
} }
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.enableWDR = config.enableWDR(); this.enableWDR = config.enableWDR();
this.enableRuneWatch = config.enableRuneWatch(); this.enableRuneWatch = config.enableRuneWatch();
@@ -173,12 +186,14 @@ public class BanListPlugin extends Plugin
public void onClanMemberJoined(ClanMemberJoined event) public void onClanMemberJoined(ClanMemberJoined event)
{ {
ClanMember member = event.getMember(); ClanMember member = event.getMember();
ListType scamList = checkScamList(Text.standardize(member.getUsername())); String memberUsername = Text.standardize(member.getUsername().toLowerCase());
ListType toxicList = checkToxicList(Text.standardize(member.getUsername()));
ListType scamList = checkScamList(memberUsername);
ListType toxicList = checkToxicList(memberUsername);
if (scamList != null) if (scamList != null)
{ {
sendWarning(Text.standardize(member.getUsername()), scamList); sendWarning(memberUsername, scamList);
if (this.highlightInClan) if (this.highlightInClan)
{ {
highlightRedInCC(); highlightRedInCC();
@@ -187,7 +202,7 @@ public class BanListPlugin extends Plugin
if (toxicList != null) if (toxicList != null)
{ {
sendWarning(Text.standardize(member.getUsername()), toxicList); sendWarning(memberUsername, toxicList);
if (this.highlightInClan) if (this.highlightInClan)
{ {
highlightRedInCC(); highlightRedInCC();
@@ -201,14 +216,12 @@ public class BanListPlugin extends Plugin
@Subscribe @Subscribe
public void onWidgetLoaded(WidgetLoaded widgetLoaded) public void onWidgetLoaded(WidgetLoaded widgetLoaded)
{ {
if (this.highlightInTrade) if (this.highlightInTrade && widgetLoaded.getGroupId() == TRADING_SCREEN)
{
if (widgetLoaded.getGroupId() == 335)
{ //if trading window was loaded { //if trading window was loaded
clientThread.invokeLater(() -> clientThread.invokeLater(() ->
{ {
Widget tradingWith = client.getWidget(335, 31); Widget tradingWith = client.getWidget(335, 31);
String name = tradingWith.getText().replaceAll("Trading With: ", ""); String name = tradingWith.getText().replaceAll("Trading With: ", "").toLowerCase();
if (checkScamList(name) != null) if (checkScamList(name) != null)
{ {
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>")); tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>"));
@@ -220,36 +233,26 @@ public class BanListPlugin extends Plugin
}); });
} }
} }
}
/** /**
* Compares player name to everything in the ban lists * Compares player name to everything in the ban lists
*/ */
private ListType checkScamList(String nameToBeChecked) private ListType checkScamList(String nameToBeChecked)
{ {
if (wdrScamArrayList.size() > 0 && this.enableWDR) if (wdrScamSet.size() > 0 && this.enableWDR && wdrScamSet.contains(nameToBeChecked))
{
if (wdrScamArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{ {
return ListType.WEDORAIDSSCAM_LIST; return ListType.WEDORAIDSSCAM_LIST;
} }
}
if (runeWatchArrayList.size() > 0 && this.enableRuneWatch) if (runeWatchSet.size() > 0 && this.enableRuneWatch && runeWatchSet.contains(nameToBeChecked))
{
if (runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{ {
return ListType.RUNEWATCH_LIST; return ListType.RUNEWATCH_LIST;
} }
}
if (manualBans.size() > 0) if (manualBans.size() > 0 && manualBans.contains(nameToBeChecked))
{
if (manualBans.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{ {
return ListType.MANUAL_LIST; return ListType.MANUAL_LIST;
} }
}
return null; return null;
} }
@@ -257,13 +260,10 @@ public class BanListPlugin extends Plugin
private ListType checkToxicList(String nameToBeChecked) private ListType checkToxicList(String nameToBeChecked)
{ {
if (wdrToxicArrayList.size() > 0 && this.enableWDR) if (wdrToxicSet.size() > 0 && this.enableWDR && wdrToxicSet.contains(nameToBeChecked))
{
if (wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{ {
return ListType.WEDORAIDSTOXIC_LIST; return ListType.WEDORAIDSTOXIC_LIST;
} }
}
return null; return null;
} }
@@ -354,9 +354,9 @@ public class BanListPlugin extends Plugin
ArrayList<String> wdrList = new ArrayList<>(Arrays.asList(text.split(","))); ArrayList<String> wdrList = new ArrayList<>(Arrays.asList(text.split(",")));
ArrayList<String> wdrList2 = new ArrayList<>(); ArrayList<String> wdrList2 = new ArrayList<>();
wdrList.forEach((name) -> wdrList2.add(Text.standardize(name))); wdrList.forEach((name) -> wdrList2.add(Text.standardize(name).toLowerCase()));
wdrScamArrayList.addAll(wdrList2); wdrScamSet.addAll(wdrList2);
} }
}); });
@@ -382,9 +382,9 @@ public class BanListPlugin extends Plugin
{ {
if (x.contains("title")) if (x.contains("title"))
{ {
x = x.substring(x.indexOf("title"), x.indexOf(">")); x = x.substring(x.indexOf("title"), x.indexOf('>'));
x = x.substring(x.indexOf("=") + 2, x.length() - 1); x = x.substring(x.indexOf('=') + 2, x.length() - 1);
runeWatchArrayList.add(Text.standardize(x)); runeWatchSet.add(Text.standardize(x).toLowerCase());
} }
} }
} }
@@ -411,9 +411,9 @@ public class BanListPlugin extends Plugin
ArrayList<String> wdrToxicList = new ArrayList<>(Arrays.asList(text.split(","))); ArrayList<String> wdrToxicList = new ArrayList<>(Arrays.asList(text.split(",")));
ArrayList<String> wdrToxicList2 = new ArrayList<>(); ArrayList<String> wdrToxicList2 = new ArrayList<>();
wdrToxicList.forEach((name) -> wdrToxicList2.add(Text.standardize(name))); wdrToxicList.forEach((name) -> wdrToxicList2.add(Text.standardize(name).toLowerCase()));
wdrToxicArrayList.addAll(wdrToxicList2); wdrToxicSet.addAll(wdrToxicList2);
} }
}); });
} }
@@ -428,8 +428,8 @@ public class BanListPlugin extends Plugin
Widget widget = client.getWidget(WidgetInfo.CLAN_CHAT_LIST); Widget widget = client.getWidget(WidgetInfo.CLAN_CHAT_LIST);
for (Widget widgetChild : widget.getDynamicChildren()) for (Widget widgetChild : widget.getDynamicChildren())
{ {
ListType scamList = checkScamList(widgetChild.getText()); ListType scamList = checkScamList(widgetChild.getText().toLowerCase());
ListType toxicList = checkToxicList(widgetChild.getText()); ListType toxicList = checkToxicList(widgetChild.getText().toLowerCase());
if (scamList != null) if (scamList != null)
{ {
@@ -26,6 +26,7 @@
package net.runelite.client.plugins.barbarianassault; package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import java.util.List;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -41,7 +42,7 @@ class BarbarianAssaultMenu
{ {
private final MenuManager menuManager; private final MenuManager menuManager;
private final BarbarianAssaultPlugin game; private final BarbarianAssaultPlugin game;
private final ArrayList<ComparableEntry> tracker = new ArrayList<>(); private final List<ComparableEntry> tracker = new ArrayList<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
private boolean hornUpdated = false; private boolean hornUpdated = false;
@@ -58,7 +59,7 @@ class BarbarianAssaultMenu
private boolean isHornOptionHidden(String option) private boolean isHornOptionHidden(String option)
{ {
if (game.isInGame() && game.getRole() != null && game.getRole().getTell(game.getLastCallText()).toLowerCase().equals(option)) if (game.isInGame() && game.getRole() != null && game.getRole().getTell(game.getLastCallText()).equalsIgnoreCase(option))
{ {
// This will force the menu to be rebuilt after the correct tell is found // This will force the menu to be rebuilt after the correct tell is found
// medic will be added to the menu if it wasn't there before // medic will be added to the menu if it wasn't there before
@@ -29,7 +29,6 @@ package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@@ -42,12 +41,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
@@ -186,16 +183,16 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private Font font = null; private Font font = null;
@Getter @Getter
private final HashMap<WorldPoint, Integer> redEggs = new HashMap<>(); private final Map<WorldPoint, Integer> redEggs = new HashMap<>();
@Getter @Getter
private final HashMap<WorldPoint, Integer> greenEggs = new HashMap<>(); private final Map<WorldPoint, Integer> greenEggs = new HashMap<>();
@Getter @Getter
private final HashMap<WorldPoint, Integer> blueEggs = new HashMap<>(); private final Map<WorldPoint, Integer> blueEggs = new HashMap<>();
@Getter @Getter
private final HashMap<WorldPoint, Integer> yellowEggs = new HashMap<>(); private final Map<WorldPoint, Integer> yellowEggs = new HashMap<>();
@Getter @Getter
private final Map<Integer, Healer> healers = new HashMap<>(); private final Map<Integer, Healer> healers = new HashMap<>();
@@ -206,7 +203,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
@Getter @Getter
private String lastListenText = null; private String lastListenText = null;
private String lastClickedTell = null; // private String lastClickedTell = null;
private int lastCallColor = -1; private int lastCallColor = -1;
@@ -216,7 +213,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private int tickNum = 0; private int tickNum = 0;
private int gameTick = -1; // private int gameTick = -1;
private int inGameBit = 0; private int inGameBit = 0;
@@ -237,9 +234,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private BufferedImage torsoImage, fighterImage, healerImage, rangerImage, runnerImage; private BufferedImage torsoImage, fighterImage, healerImage, rangerImage, runnerImage;
private ArrayList<TimerBox> deathTimes = new ArrayList<>(); private final List<TimerBox> deathTimes = new ArrayList<>();
private HashMap<Integer, Projectile> projectiles = new HashMap<>(); private final Map<Integer, Projectile> projectiles = new HashMap<>();
private TimerBox tickCounter; private TimerBox tickCounter;
@@ -341,7 +338,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
controlDown = false; controlDown = false;
resetWave(); resetWave();
wave = null; wave = null;
gameTick = client.getTickCount(); // gameTick = client.getTickCount();
menu.disableSwaps(true); menu.disableSwaps(true);
menu.clearHiddenMenus(); menu.clearHiddenMenus();
} }
@@ -452,7 +449,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.swapLadder = config.swapLadder(); this.swapLadder = config.swapLadder();
this.showTimer = config.showTimer(); this.showTimer = config.showTimer();
@@ -648,7 +645,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
return; return;
} }
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemSpawned.getItem().getId()); Map<WorldPoint, Integer> eggMap = getEggMap(itemSpawned.getItem().getId());
if (eggMap != null) if (eggMap != null)
{ {
WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation(); WorldPoint worldPoint = itemSpawned.getTile().getWorldLocation();
@@ -677,7 +674,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
// If an egg despawns due to time and the collector is standing over it, // If an egg despawns due to time and the collector is standing over it,
// a point will added as if the player picked it up // a point will added as if the player picked it up
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemId); Map<WorldPoint, Integer> eggMap = getEggMap(itemId);
if (eggMap != null) if (eggMap != null)
{ {
WorldPoint worldPoint = itemDespawned.getTile().getWorldLocation(); WorldPoint worldPoint = itemDespawned.getTile().getWorldLocation();
@@ -760,14 +757,11 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
String name = event.getNpc().getName(); String name = event.getNpc().getName();
if (name.equals("Penance Healer")) if (name.equals("Penance Healer") && !healers.containsKey(npc.getIndex()))
{
if (!healers.containsKey(npc.getIndex()))
{ {
healers.put(npc.getIndex(), new Healer(npc, healers.size(), stage)); healers.put(npc.getIndex(), new Healer(npc, healers.size(), stage));
} }
} }
}
@Subscribe @Subscribe
public void onNpcDespawned(NpcDespawned event) public void onNpcDespawned(NpcDespawned event)
@@ -1160,16 +1154,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
String target = Text.removeTags(event.getTarget()).toLowerCase(); String target = Text.removeTags(event.getTarget()).toLowerCase();
if (getRole() == Role.HEALER) if (getRole() == Role.HEALER && (target.startsWith("poisoned meat -> penance healer")
{
if (target.startsWith("poisoned meat -> penance healer")
|| target.startsWith("poisoned tofu -> penance healer") || target.startsWith("poisoned tofu -> penance healer")
|| target.startsWith("poisoned worms -> penance healer")) || target.startsWith("poisoned worms -> penance healer")))
{ {
lastHealerPoisoned = event.getIdentifier(); lastHealerPoisoned = event.getIdentifier();
poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->"); poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->");
return;
}
} }
// INW // INW
@@ -1206,15 +1196,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
if (opponent == null) if (opponent == null)
{ {
if (lastInteracted != -1) if (lastInteracted != -1 && StringUtils.equalsIgnoreCase(poisonUsed, getRole().getListen(client)) && healers.containsKey(lastInteracted))
{
if (StringUtils.equalsIgnoreCase(poisonUsed, getRole().getListen(client)) && healers.containsKey(lastInteracted))
{ {
Healer healer = healers.get(lastInteracted); Healer healer = healers.get(lastInteracted);
healer.setFoodRemaining(healer.getFoodRemaining() - 1); healer.setFoodRemaining(healer.getFoodRemaining() - 1);
healer.setTimeLastPoisoned(Instant.now()); healer.setTimeLastPoisoned(Instant.now());
} }
}
lastInteracted = -1; lastInteracted = -1;
poisonUsed = null; poisonUsed = null;
@@ -1263,7 +1250,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
lastListenText = null; lastListenText = null;
lastCallText = null; lastCallText = null;
lastCallColor = -1; lastCallColor = -1;
lastClickedTell = null; // lastClickedTell = null;
} }
else else
{ {
@@ -1385,12 +1372,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
if (newCallColor == COLOR_CALL_CALLED) if (newCallColor == COLOR_CALL_CALLED)
{ {
lastCallColor = COLOR_CALL_CALLED; lastCallColor = COLOR_CALL_CALLED;
lastClickedTell = lastCallText; // lastClickedTell = lastCallText;
} }
else if (callTimer == null) else if (callTimer == null)
{ {
lastCallColor = COLOR_CALL_UPDATED; lastCallColor = COLOR_CALL_UPDATED;
lastClickedTell = null; // lastClickedTell = null;
} }
if (callWidget != null) if (callWidget != null)
@@ -1603,7 +1590,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
yellowEggs.clear(); yellowEggs.clear();
} }
private HashMap<WorldPoint, Integer> getEggMap(int itemID) private Map<WorldPoint, Integer> getEggMap(int itemID)
{ {
switch (itemID) switch (itemID)
{ {
@@ -28,6 +28,7 @@ package net.runelite.client.plugins.barbarianassault;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
@@ -41,7 +42,7 @@ public class Scorecard
private BarbarianAssaultPlugin game; private BarbarianAssaultPlugin game;
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
private ArrayList<Wave> waves = new ArrayList<>(); private List<Wave> waves = new ArrayList<>();
private String[] totalDescriptions = { private String[] totalDescriptions = {
"A: ", "A: ",
"; D: ", "; D: ",
@@ -67,15 +68,12 @@ public class Scorecard
@Subscribe @Subscribe
public void onChatMessage(ChatMessage chatMessage) public void onChatMessage(ChatMessage chatMessage)
{ {
if (chatMessage.getMessage().startsWith("---- Points:")) if (chatMessage.getMessage().startsWith("---- Points:") && game.getStage() == 1)
{
if (game.getStage() == 1)
{ {
totalPoints = new int[6]; totalPoints = new int[6];
totalAmounts = new int[6]; totalAmounts = new int[6];
} }
} }
}
void addWave(Wave wave) void addWave(Wave wave)
{ {
@@ -207,7 +207,7 @@ public class BarrowsPlugin extends Plugin
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.showMinimap = config.showMinimap(); this.showMinimap = config.showMinimap();
this.showBrotherLoc = config.showBrotherLoc(); this.showBrotherLoc = config.showBrotherLoc();
@@ -289,9 +289,7 @@ public class BarrowsPlugin extends Plugin
ladders.clear(); ladders.clear();
puzzleAnswer = null; puzzleAnswer = null;
} }
else if (event.getGameState() == GameState.LOGGED_IN) else if (event.getGameState() == GameState.LOGGED_IN && client.getLocalPlayer() != null)
{
if (client.getLocalPlayer() != null)
{ {
boolean isInCrypt = isInCrypt(); boolean isInCrypt = isInCrypt();
if (wasInCrypt && !isInCrypt) if (wasInCrypt && !isInCrypt)
@@ -304,7 +302,6 @@ public class BarrowsPlugin extends Plugin
} }
} }
} }
}
@Subscribe @Subscribe
public void onWidgetLoaded(WidgetLoaded event) public void onWidgetLoaded(WidgetLoaded event)
@@ -117,12 +117,9 @@ public class BlackjackPlugin extends Plugin
@Subscribe @Subscribe
public void onChatMessage(ChatMessage event) public void onChatMessage(ChatMessage event)
{ {
if (event.getType() == ChatMessageType.SPAM) if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && this.pickpocketOnAggro))
{
if (event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && this.pickpocketOnAggro))
{ {
nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4); nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4);
} }
} }
} }
}
@@ -210,7 +210,7 @@ public class BlastFurnacePlugin extends Plugin
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.showBarDispenser = config.showBarDispenser(); this.showBarDispenser = config.showBarDispenser();
this.showConveyorBelt = config.showConveyorBelt(); this.showConveyorBelt = config.showConveyorBelt();
@@ -106,7 +106,7 @@ public class BoostsPlugin extends Plugin
private int lastChangeUp = -1; private int lastChangeUp = -1;
private boolean preserveBeenActive = false; private boolean preserveBeenActive = false;
private long lastTickMillis; private long lastTickMillis;
private List<String> boostedSkillsChanged = new ArrayList<>(); private final List<String> boostedSkillsChanged = new ArrayList<>();
private boolean enableSkill; private boolean enableSkill;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -29,7 +29,7 @@ import java.awt.image.BufferedImage;
import net.runelite.client.ui.overlay.infobox.InfoBox; import net.runelite.client.ui.overlay.infobox.InfoBox;
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority; import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
public class StatChangeIndicator extends InfoBox class StatChangeIndicator extends InfoBox
{ {
private final boolean up; private final boolean up;
private final BoostsPlugin plugin; private final BoostsPlugin plugin;
@@ -28,7 +28,7 @@ import java.awt.Color;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import net.runelite.client.ui.overlay.infobox.InfoBox; import net.runelite.client.ui.overlay.infobox.InfoBox;
public class CannonCounter extends InfoBox class CannonCounter extends InfoBox
{ {
private final CannonPlugin plugin; private final CannonPlugin plugin;
@@ -229,16 +229,14 @@ public class CannonPlugin extends Plugin
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
Player localPlayer = client.getLocalPlayer(); Player localPlayer = client.getLocalPlayer();
if (gameObject.getId() == CANNON_BASE && !cannonPlaced) if (gameObject.getId() == CANNON_BASE && !cannonPlaced &&
{ localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 &&
if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 localPlayer.getAnimation() == AnimationID.BURYING_BONES)
&& localPlayer.getAnimation() == AnimationID.BURYING_BONES)
{ {
cannonPosition = gameObject.getWorldLocation(); cannonPosition = gameObject.getWorldLocation();
cannon = gameObject; cannon = gameObject;
} }
} }
}
@Subscribe @Subscribe
public void onProjectileMoved(ProjectileMoved event) public void onProjectileMoved(ProjectileMoved event)
@@ -250,20 +248,18 @@ public class CannonPlugin extends Plugin
WorldPoint projectileLoc = WorldPoint.fromLocal(client, projectile.getX1(), projectile.getY1(), client.getPlane()); WorldPoint projectileLoc = WorldPoint.fromLocal(client, projectile.getX1(), projectile.getY1(), client.getPlane());
//Check to see if projectile x,y is 0 else it will continuously decrease while ball is flying. //Check to see if projectile x,y is 0 else it will continuously decrease while ball is flying.
if (projectileLoc.equals(cannonPosition) && projectile.getX() == 0 && projectile.getY() == 0) if (projectileLoc.equals(cannonPosition) && projectile.getX() == 0 && projectile.getY() == 0 &&
{
// When there's a chat message about cannon reloaded/unloaded/out of ammo, // When there's a chat message about cannon reloaded/unloaded/out of ammo,
// the message event runs before the projectile event. However they run // the message event runs before the projectile event. However they run
// in the opposite order on the server. So if both fires in the same tick, // in the opposite order on the server. So if both fires in the same tick,
// we don't want to update the cannonball counter if it was set to a specific // we don't want to update the cannonball counter if it was set to a specific
// amount. // amount.
if (!skipProjectileCheckThisTick) !skipProjectileCheckThisTick)
{ {
cballsLeft--; cballsLeft--;
} }
} }
} }
}
@Subscribe @Subscribe
public void onChatMessage(ChatMessage event) public void onChatMessage(ChatMessage event)
@@ -366,14 +362,11 @@ public class CannonPlugin extends Plugin
{ {
return Color.orange; return Color.orange;
} }
else if (cballsLeft <= this.ammoAmount) else if (cballsLeft <= this.ammoAmount && this.notifyAmmoLeft && !lock)
{
if (this.notifyAmmoLeft && !lock)
{ {
notifier.notify("Your cannon has " + this.ammoAmount + " balls left!"); notifier.notify("Your cannon has " + this.ammoAmount + " balls left!");
lock = true; lock = true;
} }
}
return Color.red; return Color.red;
} }
@@ -818,7 +818,7 @@ public class ChatCommandsPlugin extends Plugin
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); log.error("Error looking up prices", e);
} }
int itemId = item.getId(); int itemId = item.getId();
@@ -1166,7 +1166,7 @@ public class ChatCommandsPlugin extends Plugin
ItemPrice shortest = null; ItemPrice shortest = null;
for (ItemPrice item : items) for (ItemPrice item : items)
{ {
if (item.getName().toLowerCase().equals(originalInput.toLowerCase())) if (item.getName().equalsIgnoreCase(originalInput.toLowerCase()))
{ {
return item; return item;
} }
@@ -34,7 +34,7 @@ import net.runelite.client.callback.ClientThread;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
@Singleton @Singleton
public class ChatKeyboardListener implements KeyListener class ChatKeyboardListener implements KeyListener
{ {
@Inject @Inject
private ChatCommandsConfig chatCommandsConfig; private ChatCommandsConfig chatCommandsConfig;
@@ -143,14 +143,12 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
case MODPRIVATECHAT: case MODPRIVATECHAT:
final String name = Text.removeTags(chatMessage.getName()); final String name = Text.removeTags(chatMessage.getName());
// Remove to ensure uniqueness & its place in history // Remove to ensure uniqueness & its place in history
if (!friends.remove(name)) if (!friends.remove(name) &&
{
// If the friend didn't previously exist ensure deque capacity doesn't increase by adding them // If the friend didn't previously exist ensure deque capacity doesn't increase by adding them
if (friends.size() >= FRIENDS_MAX_SIZE) friends.size() >= FRIENDS_MAX_SIZE)
{ {
friends.remove(); friends.remove();
} }
}
friends.add(name); friends.add(name);
// intentional fall-through // intentional fall-through
case PUBLICCHAT: case PUBLICCHAT:
@@ -82,7 +82,7 @@ public class ChatNotificationsPlugin extends Plugin
private Pattern highlightMatcher = null; private Pattern highlightMatcher = null;
// Private message cache used to avoid duplicate notifications from ChatHistory. // Private message cache used to avoid duplicate notifications from ChatHistory.
private Set<Integer> privateMessageHashes = new HashSet<>(); private final Set<Integer> privateMessageHashes = new HashSet<>();
private boolean highlightOwnName; private boolean highlightOwnName;
private String highlightWordsString; private String highlightWordsString;
@@ -3,8 +3,20 @@ package net.runelite.client.plugins.chattranslation;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.event.KeyEvent;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.*; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.MessageNode;
import static net.runelite.api.ScriptID.CHATBOX_TEXT;
import net.runelite.api.VarClientStr;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
@@ -24,11 +36,6 @@ import net.runelite.client.plugins.PluginType;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import javax.inject.Inject;
import javax.inject.Provider;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
@PluginDescriptor( @PluginDescriptor(
name = "Chat Translator", name = "Chat Translator",
description = "Translates messages from one Language to another.", description = "Translates messages from one Language to another.",
@@ -36,6 +43,7 @@ import java.util.ArrayList;
type = PluginType.UTILITY type = PluginType.UTILITY
) )
@Singleton @Singleton
@Slf4j
public class ChatTranslationPlugin extends Plugin implements KeyListener public class ChatTranslationPlugin extends Plugin implements KeyListener
{ {
@@ -43,7 +51,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", "Kick"); private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message", "Add ignore", "Remove friend", "Kick");
private ArrayList<String> playerNames = new ArrayList<>(); private final Set<String> playerNames = new HashSet<>();
@Inject @Inject
private Client client; private Client client;
@@ -84,13 +92,10 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
{ {
updateConfig(); updateConfig();
if (client != null) if (client != null && this.translateOptionVisable)
{
if (this.translateOptionVisable)
{ {
menuManager.get().addPlayerMenuItem(TRANSLATE); menuManager.get().addPlayerMenuItem(TRANSLATE);
} }
}
keyManager.registerKeyListener(this); keyManager.registerKeyListener(this);
playerNames.addAll(Text.fromCSV(config.getPlayerNames())); playerNames.addAll(Text.fromCSV(config.getPlayerNames()));
@@ -99,13 +104,10 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
if (client != null) if (client != null && this.translateOptionVisable)
{
if (this.translateOptionVisable)
{ {
menuManager.get().removePlayerMenuItem(TRANSLATE); menuManager.get().removePlayerMenuItem(TRANSLATE);
} }
}
keyManager.unregisterKeyListener(this); keyManager.unregisterKeyListener(this);
playerNames.clear(); playerNames.clear();
@@ -143,8 +145,6 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
if (groupId == WidgetInfo.CHATBOX.getGroupId()) if (groupId == WidgetInfo.CHATBOX.getGroupId())
{ {
boolean after;
if (!AFTER_OPTIONS.contains(option)) if (!AFTER_OPTIONS.contains(option))
{ {
return; return;
@@ -223,7 +223,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); log.warn(e.toString());
} }
client.refreshChat(); client.refreshChat();
@@ -246,9 +246,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT); Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT);
if (chatboxParent != null && chatboxParent.getOnKeyListener() != null) if (chatboxParent != null && chatboxParent.getOnKeyListener() != null && event.getKeyCode() == 0xA)
{
if (event.getKeyCode() == 0xA)
{ {
Translator translator = new Translator(); Translator translator = new Translator();
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT); String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
@@ -261,7 +259,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); log.warn("Translation error", e);
} }
return; return;
} }
@@ -277,16 +275,13 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation); client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
clientThread.invoke(() -> clientThread.invoke(() ->
{ client.runScript(CHATBOX_TEXT, 0, translation));
client.runScript(96, 0, translation);
});
} }
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""); client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); log.warn(e.toString());
}
} }
} }
} }
@@ -9,7 +9,7 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
public class Translator class Translator
{ {
public String translate(String source, String target, String message) throws Exception public String translate(String source, String target, String message) throws Exception
@@ -23,7 +23,7 @@ public class Translator
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine; String inputLine;
StringBuffer response = new StringBuffer(); StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) while ((inputLine = in.readLine()) != null)
{ {
@@ -121,13 +121,13 @@ public class ClanChatPlugin extends Plugin
return (CopyOnWriteArrayList<Player>) clanMembers.clone(); return (CopyOnWriteArrayList<Player>) clanMembers.clone();
} }
private static CopyOnWriteArrayList<Player> clanMembers = new CopyOnWriteArrayList<>(); private static final CopyOnWriteArrayList<Player> clanMembers = new CopyOnWriteArrayList<>();
private ClanChatIndicator clanMemberCounter; private ClanChatIndicator clanMemberCounter;
/** /**
* queue of temporary messages added to the client * queue of temporary messages added to the client
*/ */
private final Deque<ClanJoinMessage> clanJoinMessages = new ArrayDeque<>(); private final Deque<ClanJoinMessage> clanJoinMessages = new ArrayDeque<>();
private Map<String, ClanMemberActivity> activityBuffer = new HashMap<>(); private final Map<String, ClanMemberActivity> activityBuffer = new HashMap<>();
private int clanJoinedTick; private int clanJoinedTick;
private boolean clanChatIcons; private boolean clanChatIcons;
@@ -151,7 +151,7 @@ public class ClanChatPlugin extends Plugin
public void startUp() public void startUp()
{ {
updateConfig(); updateConfig();
chats = new ArrayList<>(Text.fromCSV(config.chatsData())); chats = new ArrayList<>(Text.fromCSV(this.chatsData));
} }
@Override @Override
@@ -485,7 +485,7 @@ public class ClanChatPlugin extends Plugin
final Player local = client.getLocalPlayer(); final Player local = client.getLocalPlayer();
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (player != local && player.isClanMember()) if (player != null && !player.equals(local) && player.isClanMember())
{ {
clanMembers.add(player); clanMembers.add(player);
addClanCounter(); addClanCounter();
@@ -16,12 +16,12 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ClanManModeMinimapOverlay extends Overlay public class ClanManModeMinimapOverlay extends Overlay
{ {
private final ClanManModeService ClanManModeService; private final ClanManModeService ClanManModeService;
private final ClanManModeConfig config; private final ClanManModePlugin plugin;
@Inject @Inject
private ClanManModeMinimapOverlay(final ClanManModeConfig config, final ClanManModeService ClanManModeService) private ClanManModeMinimapOverlay(final ClanManModePlugin plugin, final ClanManModeService ClanManModeService)
{ {
this.config = config; this.plugin = plugin;
this.ClanManModeService = ClanManModeService; this.ClanManModeService = ClanManModeService;
setLayer(OverlayLayer.ABOVE_WIDGETS); setLayer(OverlayLayer.ABOVE_WIDGETS);
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
@@ -39,7 +39,7 @@ public class ClanManModeMinimapOverlay extends Overlay
{ {
final String name = actor.getName().replace('\u00A0', ' '); final String name = actor.getName().replace('\u00A0', ' ');
if (config.drawMinimapNames()) if (plugin.isDrawMinimapNames())
{ {
final net.runelite.api.Point minimapLocation = actor.getMinimapLocation(); final net.runelite.api.Point minimapLocation = actor.getMinimapLocation();
@@ -17,12 +17,12 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ClanManModeOverlay extends Overlay public class ClanManModeOverlay extends Overlay
{ {
private final ClanManModeService ClanManModeService; private final ClanManModeService ClanManModeService;
private final ClanManModeConfig config; private final ClanManModePlugin plugin;
@Inject @Inject
private ClanManModeOverlay(final ClanManModeConfig config, final ClanManModeService ClanManModeService) private ClanManModeOverlay(final ClanManModePlugin plugin, final ClanManModeService ClanManModeService)
{ {
this.config = config; this.plugin = plugin;
this.ClanManModeService = ClanManModeService; this.ClanManModeService = ClanManModeService;
setPosition(OverlayPosition.DYNAMIC); setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.MED); setPriority(OverlayPriority.MED);
@@ -37,7 +37,7 @@ public class ClanManModeOverlay extends Overlay
private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color)
{ {
if (!config.drawOverheadPlayerNames()) if (!plugin.isDrawOverheadPlayerNames())
{ {
return; return;
} }
@@ -48,7 +48,7 @@ public class ClanManModeOverlay extends Overlay
if (textLocation != null) if (textLocation != null)
{ {
if (config.getClanAttackableColor().equals(color) && config.ShowBold()) if (plugin.getGetClanAttackableColor().equals(color) && plugin.isShowBold())
{ {
graphics.setFont(FontManager.getRunescapeBoldFont()); graphics.setFont(FontManager.getRunescapeBoldFont());
} }
@@ -1,11 +1,14 @@
package net.runelite.client.plugins.clanmanmode; package net.runelite.client.plugins.clanmanmode;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Color;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Player; import net.runelite.api.Player;
@@ -49,6 +52,37 @@ public class ClanManModePlugin extends Plugin
@Inject @Inject
private Client client; private Client client;
@Getter(AccessLevel.PACKAGE)
private boolean highlightAttackable;
@Getter(AccessLevel.PACKAGE)
private Color getAttackableColor;
@Getter(AccessLevel.PACKAGE)
private boolean highlightAttacked;
@Getter(AccessLevel.PACKAGE)
private Color getClanAttackableColor;
@Getter(AccessLevel.PACKAGE)
private boolean drawTiles;
@Getter(AccessLevel.PACKAGE)
private boolean drawOverheadPlayerNames;
@Getter(AccessLevel.PACKAGE)
private boolean drawMinimapNames;
@Getter(AccessLevel.PACKAGE)
private boolean showAttackers;
@Getter(AccessLevel.PACKAGE)
private Color getAttackerColor;
@Getter(AccessLevel.PACKAGE)
private boolean ShowBold;
@Getter(AccessLevel.PACKAGE)
private boolean hideAttackable;
@Getter(AccessLevel.PACKAGE)
private int hideTime;
@Getter(AccessLevel.PACKAGE)
private boolean CalcSelfCB;
@Getter(AccessLevel.PACKAGE)
private boolean PersistentClan;
@Getter(AccessLevel.PACKAGE)
private Color getClanMemberColor;
@Provides @Provides
ClanManModeConfig provideConfig(ConfigManager configManager) ClanManModeConfig provideConfig(ConfigManager configManager)
{ {
@@ -60,11 +94,13 @@ public class ClanManModePlugin extends Plugin
int clanmax; int clanmax;
int inwildy; int inwildy;
int ticks; int ticks;
Map<String, Integer> clan = new HashMap<>(); final Map<String, Integer> clan = new HashMap<>();
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig();
overlayManager.add(ClanManModeOverlay); overlayManager.add(ClanManModeOverlay);
overlayManager.add(ClanManModeTileOverlay); overlayManager.add(ClanManModeTileOverlay);
overlayManager.add(ClanManModeMinimapOverlay); overlayManager.add(ClanManModeMinimapOverlay);
@@ -91,6 +127,8 @@ public class ClanManModePlugin extends Plugin
{ {
return; return;
} }
updateConfig();
} }
@Subscribe @Subscribe
@@ -122,4 +160,23 @@ public class ClanManModePlugin extends Plugin
clanmax = Collections.max(clan.values()); clanmax = Collections.max(clan.values());
} }
} }
private void updateConfig()
{
this.highlightAttackable = config.highlightAttackable();
this.getAttackableColor = config.getAttackableColor();
this.highlightAttacked = config.highlightAttacked();
this.getClanAttackableColor = config.getClanAttackableColor();
this.drawTiles = config.drawTiles();
this.drawOverheadPlayerNames = config.drawOverheadPlayerNames();
this.drawMinimapNames = config.drawMinimapNames();
this.showAttackers = config.showAttackers();
this.getAttackerColor = config.getAttackerColor();
this.ShowBold = config.ShowBold();
this.hideAttackable = config.hideAttackable();
this.hideTime = config.hideTime();
this.CalcSelfCB = config.CalcSelfCB();
this.PersistentClan = config.PersistentClan();
this.getClanMemberColor = config.getClanMemberColor();
}
} }
@@ -16,18 +16,16 @@ import net.runelite.api.coords.WorldPoint;
public class ClanManModeService public class ClanManModeService
{ {
private final Client client; private final Client client;
private final ClanManModeConfig config;
private final ClanManModePlugin plugin; private final ClanManModePlugin plugin;
@Inject @Inject
private ClanManModeService(final Client client, final ClanManModeConfig config, final ClanManModePlugin plugin) private ClanManModeService(final Client client, final ClanManModePlugin plugin)
{ {
this.config = config;
this.client = client; this.client = client;
this.plugin = plugin; this.plugin = plugin;
} }
private Map<String, String> interactors = new HashMap<>(); private final Map<String, String> interactors = new HashMap<>();
public void forEachPlayer(final BiConsumer<Player, Color> consumer) public void forEachPlayer(final BiConsumer<Player, Color> consumer)
{ {
@@ -39,12 +37,7 @@ public class ClanManModeService
int selfmax = localPlayer.getCombatLevel() + plugin.wildernessLevel; int selfmax = localPlayer.getCombatLevel() + plugin.wildernessLevel;
for (Player player : client.getPlayers()) for (Player player : client.getPlayers())
{ {
if (player == null || player.getName() == null) if (player == null || player.getName() == null || player.equals(localPlayer))
{
continue;
}
if (player == localPlayer)
{ {
continue; continue;
} }
@@ -57,15 +50,9 @@ public class ClanManModeService
interactor = ((Player) interacting); interactor = ((Player) interacting);
} }
if (config.showAttackers()) if (plugin.isShowAttackers() && interactor != null && interactor.getName().equals(localName))
{ {
if (interactor != null) consumer.accept(player, plugin.getGetAttackerColor());
{
if (interactor.getName().equals(localName))
{
consumer.accept(player, config.getAttackerColor());
}
}
} }
if (plugin.inwildy == 1) if (plugin.inwildy == 1)
@@ -76,11 +63,7 @@ public class ClanManModeService
{ {
plugin.clan.put(player.getName(), player.getCombatLevel()); plugin.clan.put(player.getName(), player.getCombatLevel());
} }
if (config.highlightAttacked()) if (plugin.isHighlightAttacked() && interactor != null && !interactors.containsKey(interactor.getName()))
{
if (interactor != null)
{
if (!interactors.containsKey(interactor.getName()))
{ {
WorldPoint a = interactor.getWorldLocation(); WorldPoint a = interactor.getWorldLocation();
int underLevel = ((a.getY() - 9920) / 8) + 1; int underLevel = ((a.getY() - 9920) / 8) + 1;
@@ -91,12 +74,12 @@ public class ClanManModeService
{ {
wildydiff = 0; wildydiff = 0;
} }
if (config.CalcSelfCB()) if (plugin.isCalcSelfCB())
{ {
if (interacting.getCombatLevel() <= selfmax && interacting.getCombatLevel() - wildydiff >= selfmin && !interactor.isClanMember()) if (interacting.getCombatLevel() <= selfmax && interacting.getCombatLevel() - wildydiff >= selfmin && !interactor.isClanMember())
{ {
interactors.put(interactor.getName(), player.getName()); interactors.put(interactor.getName(), player.getName());
consumer.accept(interactor, config.getClanAttackableColor()); consumer.accept(interactor, plugin.getGetClanAttackableColor());
} }
} }
else else
@@ -104,25 +87,18 @@ public class ClanManModeService
if (interacting.getCombatLevel() <= maxatk && interacting.getCombatLevel() - wildydiff >= minatk && !interactor.isClanMember()) if (interacting.getCombatLevel() <= maxatk && interacting.getCombatLevel() - wildydiff >= minatk && !interactor.isClanMember())
{ {
interactors.put(interactor.getName(), player.getName()); interactors.put(interactor.getName(), player.getName());
consumer.accept(interactor, config.getClanAttackableColor()); consumer.accept(interactor, plugin.getGetClanAttackableColor());
}
}
} }
} }
} }
} }
else else
{ {
if (config.PersistentClan()) if (plugin.isPersistentClan() && plugin.clan.containsKey(player.getName()))
{ {
if (plugin.clan.containsKey(player.getName())) consumer.accept(player, plugin.getGetClanMemberColor());
{
consumer.accept(player, config.getClanMemberColor());
} }
} if (plugin.isHighlightAttacked() && interactors.containsKey(player.getName()))
if (config.highlightAttacked())
{
if (interactors.containsKey(player.getName()))
{ {
String attackername = interactors.get(player.getName()); String attackername = interactors.get(player.getName());
boolean found = false; boolean found = false;
@@ -140,7 +116,7 @@ public class ClanManModeService
{ {
if (ainteract.getName().equals(player.getName())) if (ainteract.getName().equals(player.getName()))
{ {
consumer.accept(player, config.getClanAttackableColor()); consumer.accept(player, plugin.getGetClanAttackableColor());
} }
else else
{ {
@@ -160,10 +136,9 @@ public class ClanManModeService
} }
continue; continue;
} }
} if (plugin.isHighlightAttackable())
if (config.highlightAttackable())
{ {
if ((config.hideAttackable() && plugin.ticks >= config.hideTime()) || plugin.clan.containsKey(player.getName())) if ((plugin.isHideAttackable() && plugin.ticks >= plugin.getHideTime()) || plugin.clan.containsKey(player.getName()))
{ {
continue; continue;
} }
@@ -176,18 +151,18 @@ public class ClanManModeService
{ {
wildydiff = 0; wildydiff = 0;
} }
if (config.CalcSelfCB()) if (plugin.isCalcSelfCB())
{ {
if (player.getCombatLevel() <= selfmax && player.getCombatLevel() - wildydiff >= selfmin) if (player.getCombatLevel() <= selfmax && player.getCombatLevel() - wildydiff >= selfmin)
{ {
consumer.accept(player, config.getAttackableColor()); consumer.accept(player, plugin.getGetAttackableColor());
} }
} }
else else
{ {
if (player.getCombatLevel() <= maxatk && player.getCombatLevel() - wildydiff >= minatk) if (player.getCombatLevel() <= maxatk && player.getCombatLevel() - wildydiff >= minatk)
{ {
consumer.accept(player, config.getAttackableColor()); consumer.accept(player, plugin.getGetAttackableColor());
} }
} }
} }
@@ -78,14 +78,11 @@ public class ClueScrollOverlay extends Overlay
clue.makeOverlayHint(panelComponent, plugin); clue.makeOverlayHint(panelComponent, plugin);
if (clue.isRequiresSpade() && plugin.getInventoryItems() != null) if (clue.isRequiresSpade() && plugin.getInventoryItems() != null && !HAS_SPADE.fulfilledBy(plugin.getInventoryItems()))
{
if (!HAS_SPADE.fulfilledBy(plugin.getInventoryItems()))
{ {
panelComponent.getChildren().add(LineComponent.builder().left("").build()); panelComponent.getChildren().add(LineComponent.builder().left("").build());
panelComponent.getChildren().add(LineComponent.builder().left("Requires Spade!").leftColor(Color.RED).build()); panelComponent.getChildren().add(LineComponent.builder().left("Requires Spade!").leftColor(Color.RED).build());
} }
}
return panelComponent.render(graphics); return panelComponent.render(graphics);
} }
@@ -36,10 +36,8 @@ import java.awt.Rectangle;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Stream;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.Getter; import lombok.Getter;
@@ -101,6 +99,7 @@ import net.runelite.client.ui.overlay.OverlayUtil;
import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.ui.overlay.components.TextComponent;
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager; import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.ItemUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@PluginDescriptor( @PluginDescriptor(
@@ -211,13 +210,10 @@ public class ClueScrollPlugin extends Plugin
return; return;
} }
if (clue instanceof HotColdClue) if (clue instanceof HotColdClue && ((HotColdClue) clue).update(event.getMessage(), this))
{
if (((HotColdClue) clue).update(event.getMessage(), this))
{ {
worldMapPointsSet = false; worldMapPointsSet = false;
} }
}
if (!event.getMessage().equals("The strange device cools as you find your treasure.") if (!event.getMessage().equals("The strange device cools as you find your treasure.")
&& !event.getMessage().equals("Well done, you've completed the Treasure Trail!")) && !event.getMessage().equals("Well done, you've completed the Treasure Trail!"))
@@ -231,9 +227,9 @@ public class ClueScrollPlugin extends Plugin
@Subscribe @Subscribe
public void onMenuOptionClicked(final MenuOptionClicked event) public void onMenuOptionClicked(final MenuOptionClicked event)
{ {
if (event.getMenuAction() != null && event.getMenuAction().equals("Read")) if ("read".equalsIgnoreCase(event.getOption()))
{ {
final ItemDefinition itemComposition = itemManager.getItemDefinition(event.hashCode()); final ItemDefinition itemComposition = itemManager.getItemDefinition(event.getIdentifier());
if (itemComposition != null && itemComposition.getName().startsWith("Clue scroll")) if (itemComposition != null && itemComposition.getName().startsWith("Clue scroll"))
{ {
@@ -262,19 +258,15 @@ public class ClueScrollPlugin extends Plugin
// Check if item was removed from inventory // Check if item was removed from inventory
if (clue != null && clueItemId != null) if (clue != null && clueItemId != null)
{ {
final Stream<Item> items = Arrays.stream(event.getItemContainer().getItems());
// Check if clue was removed from inventory // Check if clue was removed from inventory
if (items.noneMatch(item -> itemManager.getItemDefinition(item.getId()).getId() == clueItemId)) if (!ItemUtil.containsItemId(event.getItemContainer().getItems(), clueItemId))
{ {
resetClue(true); resetClue(true);
} }
} }
// if three step clue check for clue scroll pieces // if three step clue check for clue scroll pieces
if (clue instanceof ThreeStepCrypticClue) if (clue instanceof ThreeStepCrypticClue && ((ThreeStepCrypticClue) clue).update(client, event, itemManager))
{
if (((ThreeStepCrypticClue) clue).update(client, event, itemManager))
{ {
worldMapPointsSet = false; worldMapPointsSet = false;
npcsToMark.clear(); npcsToMark.clear();
@@ -287,7 +279,6 @@ public class ClueScrollPlugin extends Plugin
checkClueNPCs(clue, client.getCachedNPCs()); checkClueNPCs(clue, client.getCachedNPCs());
} }
} }
}
@Subscribe @Subscribe
public void onNpcSpawned(final NpcSpawned event) public void onNpcSpawned(final NpcSpawned event)
@@ -483,13 +474,10 @@ public class ClueScrollPlugin extends Plugin
final String text = Text.sanitizeMultilineText(clueScrollText.getText()).toLowerCase(); final String text = Text.sanitizeMultilineText(clueScrollText.getText()).toLowerCase();
// Early return if this is same clue as already existing one // Early return if this is same clue as already existing one
if (clue instanceof TextClueScroll) if (clue instanceof TextClueScroll && ((TextClueScroll) clue).getText().equalsIgnoreCase(text))
{
if (((TextClueScroll) clue).getText().equalsIgnoreCase(text))
{ {
return clue; return clue;
} }
}
// (This|The) anagram reveals who to speak to next: // (This|The) anagram reveals who to speak to next:
if (text.contains("anagram reveals who to speak to next:")) if (text.contains("anagram reveals who to speak to next:"))
@@ -171,11 +171,11 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (digLocations.size() > 10) if (digLocations.size() > 10)
{ {
for (HotColdArea area : locationCounts.keySet()) for (Map.Entry<HotColdArea, Integer> locationCount : locationCounts.entrySet())
{ {
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()
.left(area.getName()) .left(locationCount.getKey().getName())
.right(Integer.toString(locationCounts.get(area))) .right(Integer.toString(locationCount.getValue()))
.build()); .build());
} }
} }
@@ -29,7 +29,7 @@ import net.runelite.api.Item;
public class AllRequirementsCollection implements ItemRequirement public class AllRequirementsCollection implements ItemRequirement
{ {
private ItemRequirement[] requirements; private final ItemRequirement[] requirements;
public AllRequirementsCollection(ItemRequirement... requirements) public AllRequirementsCollection(ItemRequirement... requirements)
{ {
@@ -29,8 +29,8 @@ import net.runelite.api.Item;
public class AnyRequirementCollection implements ItemRequirement public class AnyRequirementCollection implements ItemRequirement
{ {
private String name; private final String name;
private ItemRequirement[] requirements; private final ItemRequirement[] requirements;
public AnyRequirementCollection(String name, ItemRequirement... requirements) public AnyRequirementCollection(String name, ItemRequirement... requirements)
{ {
@@ -29,9 +29,9 @@ import net.runelite.api.Item;
public class RangeItemRequirement implements ItemRequirement public class RangeItemRequirement implements ItemRequirement
{ {
private String name; private final String name;
private int startItemId; private final int startItemId;
private int endItemId; private final int endItemId;
public RangeItemRequirement(String name, int startItemId, int endItemId) public RangeItemRequirement(String name, int startItemId, int endItemId)
{ {
@@ -30,7 +30,7 @@ import net.runelite.api.ItemDefinition;
public class SingleItemRequirement implements ItemRequirement public class SingleItemRequirement implements ItemRequirement
{ {
private int itemId; private final int itemId;
public SingleItemRequirement(int itemId) public SingleItemRequirement(int itemId)
{ {
@@ -30,8 +30,8 @@ import net.runelite.api.Item;
public class SlotLimitationRequirement implements ItemRequirement public class SlotLimitationRequirement implements ItemRequirement
{ {
private String description; private final String description;
private EquipmentInventorySlot[] slots; private final EquipmentInventorySlot[] slots;
public SlotLimitationRequirement(String description, EquipmentInventorySlot... slots) public SlotLimitationRequirement(String description, EquipmentInventorySlot... slots)
{ {
@@ -24,13 +24,26 @@
*/ */
package net.runelite.client.plugins.combatcounter; package net.runelite.client.plugins.combatcounter;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import static net.runelite.api.AnimationID.BARRAGE_ANIMATION;
import static net.runelite.api.AnimationID.BLOWPIPE_ATTACK;
import static net.runelite.api.AnimationID.CHIN_ANIMATION;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Hitsplat; import net.runelite.api.Hitsplat;
import net.runelite.api.NPC; import net.runelite.api.NPC;
@@ -49,13 +62,6 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@PluginDescriptor( @PluginDescriptor(
name = "Tick Counter", name = "Tick Counter",
description = "Count the amount of perfect combat ticks performed by each player.", description = "Count the amount of perfect combat ticks performed by each player.",
@@ -64,6 +70,7 @@ import java.util.Map;
enabledByDefault = false enabledByDefault = false
) )
@Singleton @Singleton
@Slf4j
public class CombatCounter extends Plugin public class CombatCounter extends Plugin
{ {
@@ -87,9 +94,9 @@ public class CombatCounter extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Map<String, Long> counter = new HashMap<>(); private Map<String, Long> counter = new HashMap<>();
private Map<String, Long> blowpipe = new HashMap<>(); private final Map<String, Long> blowpipe = new HashMap<>();
private Map<NPC, NPCDamageCounter> npcDamageMap = new HashMap<>(); private final Map<NPC, NPCDamageCounter> npcDamageMap = new HashMap<>();
Map<String, Double> playerDamage = new HashMap<>(); Map<String, Double> playerDamage = new HashMap<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -114,130 +121,116 @@ public class CombatCounter extends Plugin
return configManager.getConfig(CombatCounterConfig.class); return configManager.getConfig(CombatCounterConfig.class);
} }
private Map<Integer, Integer> variables = new HashMap<Integer, Integer>() private static final Map<Integer, Integer> VARIABLES = ImmutableMap.<Integer, Integer>builder()
{ .put(422, 4) // Unarmed Punch, Block
{ .put(423, 4) // Unarmed Kick
this.put(422, 4); // Unarmed Punch, Block
this.put(423, 4); // Unarmed Kick
this.put(8145, 4); // Rapier Stab, Lunge, Block .put(8145, 4) // Rapier Stab, Lunge, Block
this.put(390, 4); // Rapier Slash .put(390, 4) // Rapier Slash
this.put(7552, 5); // Armadyl Crossbow Accurate, Rapid, Longrange, Special .put(7552, 5) // Armadyl Crossbow Accurate, Rapid, Longrange, Special
this.put(1167, 4); // Trident Accurate, Accurate, Longrange .put(1167, 4) // Trident Accurate, Accurate, Longrange
this.put(401, 6); // Dragon Warhammer Pound, Pummel, Block .put(401, 6) // Dragon Warhammer Pound, Pummel, Block
this.put(1378, 6); // Dragon Warhammer Special .put(1378, 6) // Dragon Warhammer Special
this.put(393, 4); // Dragon Claws Chop, Slash, Block .put(393, 4) // Dragon Claws Chop, Slash, Block
this.put(1067, 4); // Dragon Claws Lunge .put(1067, 4) // Dragon Claws Lunge
this.put(7514, 4); // Dragon Claws Special .put(7514, 4) // Dragon Claws Special
this.put(8288, 4); // Dragon Hunter Lance Lunge, Block .put(8288, 4) // Dragon Hunter Lance Lunge, Block
this.put(8289, 4); // Dragon Hunter Lance Swipe .put(8289, 4) // Dragon Hunter Lance Swipe
this.put(8290, 4); // Dragon Hunter Lance Pound .put(8290, 4) // Dragon Hunter Lance Pound
this.put(7516, 6); // Elder maul Pound, Pummel, Block .put(7516, 6) // Elder maul Pound, Pummel, Block
this.put(8056, 5); // Scythe of Vitur Reap, Chop, Jab, Block .put(8056, 5) // Scythe of Vitur Reap, Chop, Jab, Block
this.put(7045, 6); // Bandos Godsword Chop, Slash .put(7045, 6) // Bandos Godsword Chop, Slash
this.put(7054, 6); // Bandos Godsword Smash .put(7054, 6) // Bandos Godsword Smash
this.put(7055, 6); // Bandos Godsword Block .put(7055, 6) // Bandos Godsword Block
this.put(7642, 6); // Bandos Godsword Special .put(7642, 6) // Bandos Godsword Special
this.put(7643, 6); // Bandos Godsword Special (Ornamate) .put(7643, 6) // Bandos Godsword Special (Ornamate)
this.put(426, 5); // Twisted Bow Accurate, Rapid, Longrange .put(426, 5) // Twisted Bow Accurate, Rapid, Longrange
this.put(414, 5); // Kodai Bash, Pound, Focus .put(414, 5) // Kodai Bash, Pound, Focus
this.put(428, 4); // Staff of Light Jab // .put(428, 4) // Staff of Light Jab
this.put(440, 4); // Staff of Light Swipe .put(440, 4) // Staff of Light Swipe
this.put(419, 4); // Staff of Light Fend //.put(419, 4) // Staff of Light Fend
this.put(7967, 4); // Staff of Light Special .put(7967, 4) // Staff of Light Special
this.put(428, 7); // Crystal Halberd Jab, Fend .put(428, 7) // Crystal Halberd Jab, Fend
this.put(419, 7); // Crystal Halberd Swipe .put(419, 7) // Crystal Halberd Swipe
this.put(1203, 7); // Crystal Halberd Special .put(1203, 7) // Crystal Halberd Special
this.put(5061, 2); // Toxic Blowpipe Accurate, Rapid, Longrange, Special .put(5061, 2) // Toxic Blowpipe Accurate, Rapid, Longrange, Special
this.put(1979, 5); // Ancient Magicks Barrage .put(1979, 5) // Ancient Magicks Barrage
this.put(1978, 5); // Ancient Magicks Blitz .put(1978, 5) // Ancient Magicks Blitz
this.put(7618, 3); // Chinchompa Short, Medium, Long Fuse .put(7618, 3) // Chinchompa Short, Medium, Long Fuse
this.put(1658, 4); // Whip Flick, Lash, Deflect .put(1658, 4) // Whip Flick, Lash, Deflect
this.put(7555, 6); // Ballista Accurate, Rapid, Longrange .put(7555, 6) // Ballista Accurate, Rapid, Longrange
} .build();
};
private List<Integer> MELEE_ANIMATIONS = new ArrayList<Integer>()
{
{
this.add(422); // Unarmed Punch, Block
this.add(423); // Unarmed Kick
this.add(8145); // Rapier Stab, Lunge, Block private static final Set<Integer> MELEE_ANIMATIONS = ImmutableSet.<Integer>builder()
this.add(390); // Rapier Slash .add(422) // Unarmed Punch, Block
.add(423) // Unarmed Kick
this.add(401); // Dragon Warhammer Pound, Pummel, Block .add(8145) // Rapier Stab, Lunge, Block
this.add(1378); // Dragon Warhammer Special .add(390) // Rapier Slash
this.add(393); // Dragon Claws Chop, Slash, Block .add(401) // Dragon Warhammer Pound, Pummel, Block
this.add(1067); // Dragon Claws Lunge .add(1378) // Dragon Warhammer Special
this.add(7514); // Dragon Claws Special
this.add(8288); // Dragon Hunter Lance Lunge, Block .add(393) // Dragon Claws Chop, Slash, Block
this.add(8289); // Dragon Hunter Lance Swipe .add(1067) // Dragon Claws Lunge
this.add(8290); // Dragon Hunter Lance Pound .add(7514) // Dragon Claws Special
this.add(7516); // Elder maul Pound, Pummel, Block .add(8288) // Dragon Hunter Lance Lunge, Block
.add(8289) // Dragon Hunter Lance Swipe
.add(8290) // Dragon Hunter Lance Pound
this.add(8056); // Scythe of Vitur Reap, Chop, Jab, Block .add(7516) // Elder maul Pound, Pummel, Block
this.add(7045); // Bandos Godsword Chop, Slash .add(8056) // Scythe of Vitur Reap, Chop, Jab, Block
this.add(7054); // Bandos Godsword Smash
this.add(7055); // Bandos Godsword Block
this.add(7642); // Bandos Godsword Special
this.add(7643); // Bandos Godsword Special (Ornamate)
this.add(414); // Kodai Bash, Pound, Focus .add(7045) // Bandos Godsword Chop, Slash
.add(7054) // Bandos Godsword Smash
.add(7055) // Bandos Godsword Block
.add(7642) // Bandos Godsword Special
.add(7643) // Bandos Godsword Special (Ornamate)
this.add(428); // Staff of Light Jab .add(414) // Kodai Bash, Pound, Focus
this.add(440); // Staff of Light Swipe
this.add(419); // Staff of Light Fend
this.add(428); // Crystal Halberd Jab, Fend .add(428) // Staff of Light Jab
this.add(419); // Crystal Halberd Swipe .add(440) // Staff of Light Swipe
this.add(1203); // Crystal Halberd Special .add(419) // Staff of Light Fend
this.add(1658); // Whip Flick, Lash, Deflect .add(428) // Crystal Halberd Jab, Fend
} .add(419) // Crystal Halberd Swipe
}; .add(1203) // Crystal Halberd Special
private List<Integer> RANGE_ANIMATIONS = new ArrayList<Integer>() .add(1658) // Whip Flick, Lash, Deflect
{ .build();
{
this.add(7552); // Armadyl Crossbow Accurate, Rapid, Longrange, Special
this.add(426); // Twisted Bow Accurate, Rapid, Longrange private static final Set<Integer> RANGE_ANIMATIONS = ImmutableSet.of(
7552, // Armadyl Crossbow Accurate, Rapid, Longrange, Special
426, // Twisted Bow Accurate, Rapid, Longrange
7618, // Chinchompa Short, Medium, Long Fuse
7555 // Ballista Accurate, Rapid, Longrange
);
this.add(7618); // Chinchompa Short, Medium, Long Fuse private static final Set<Integer> MAGE_ANIMATIONS = ImmutableSet.of(
1167, // Trident Accurate, Accurate, Longrange
this.add(7555); // Ballista Accurate, Rapid, Longrange 1978, // Ancient Magicks Blitz
} 1979 // Ancient Magicks Barrage
}; );
private List<Integer> MAGE_ANIMATIONS = new ArrayList<Integer>()
{
{
this.add(1167); // Trident Accurate, Accurate, Longrange
this.add(1978); // Ancient Magicks Blitz
this.add(1979); // Ancient Magicks Barrage
}
};
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
@@ -279,23 +272,24 @@ public class CombatCounter extends Plugin
int animation = p.getAnimation(); int animation = p.getAnimation();
if (animation != -1) if (animation != -1)
{ {
if (variables.containsKey(animation)) if (VARIABLES.containsKey(animation))
{ {
/* /*
* This part handles the Tick Counter. * This part handles the Tick Counter.
*/ */
long ticks = variables.get(animation); long ticks = VARIABLES.get(animation);
if (((Player) actor).getPlayerAppearance().getEquipmentId(KitType.WEAPON) == 23360) if (((Player) actor).getPlayerAppearance().getEquipmentId(KitType.WEAPON) == 23360)
{ {
ticks = 3; ticks = 3;
} }
if (counter.containsKey(name)) if (counter.containsKey(name))
{
ticks += counter.get(name); ticks += counter.get(name);
}
counter.put(name, ticks); counter.put(name, ticks);
counter = sortByValue(counter); counter = sortByValue(counter);
long BLOWPIPE_ID = 5061; if (animation == BLOWPIPE_ATTACK)
if (animation == BLOWPIPE_ID)
{ {
this.blowpipe.put(name, -4L); this.blowpipe.put(name, -4L);
} }
@@ -311,7 +305,7 @@ public class CombatCounter extends Plugin
List<NPC> actives = new ArrayList<>(); List<NPC> actives = new ArrayList<>();
actives.add(npc); actives.add(npc);
if (animation == 1979 || animation == 7618) if (BARRAGE_ANIMATION == 1979 || CHIN_ANIMATION == 7618)
{ // Barrage or chin. { // Barrage or chin.
for (NPC nearby : this.client.getNpcs()) for (NPC nearby : this.client.getNpcs())
{ {
@@ -354,7 +348,7 @@ public class CombatCounter extends Plugin
} }
else else
{ {
System.out.println("Unclassified Animation: " + animation); log.debug("Unclassified Animation: {}", animation);
} }
if (delay != -1) if (delay != -1)
@@ -379,13 +373,17 @@ public class CombatCounter extends Plugin
{ {
NPCDamageCounter dc = new NPCDamageCounter(); NPCDamageCounter dc = new NPCDamageCounter();
if (this.npcDamageMap.containsKey(target)) if (this.npcDamageMap.containsKey(target))
{
dc = this.npcDamageMap.get(target); dc = this.npcDamageMap.get(target);
}
for (Integer tick : ticksToAdd) for (Integer tick : ticksToAdd)
{ {
List<String> attackers = new ArrayList<>(); List<String> attackers = new ArrayList<>();
if (dc.attackers.containsKey(tick)) if (dc.attackers.containsKey(tick))
{
attackers = dc.attackers.get(tick); attackers = dc.attackers.get(tick);
}
attackers.add(name); attackers.add(name);
dc.attackers.put(tick, attackers); dc.attackers.put(tick, attackers);
@@ -425,8 +423,10 @@ public class CombatCounter extends Plugin
for (Player p : this.client.getPlayers()) for (Player p : this.client.getPlayers())
{ {
if (p.getName() != null) if (p.getName() != null)
{
visible.put(p.getName(), p); visible.put(p.getName(), p);
} }
}
for (NPC npc : new ArrayList<>(this.npcDamageMap.keySet())) for (NPC npc : new ArrayList<>(this.npcDamageMap.keySet()))
{ {
@@ -442,7 +442,9 @@ public class CombatCounter extends Plugin
double totalDamage = 0d; double totalDamage = 0d;
for (Integer damage : counter.damage) for (Integer damage : counter.damage)
{
totalDamage += damage; totalDamage += damage;
}
if (attackers.containsKey(-1)) if (attackers.containsKey(-1))
{ {
@@ -454,7 +456,9 @@ public class CombatCounter extends Plugin
{ {
double count = 0d; double count = 0d;
if (this.playerDamage.containsKey(name)) if (this.playerDamage.containsKey(name))
{
count = this.playerDamage.get(name); count = this.playerDamage.get(name);
}
count += damagePerPlayer; count += damagePerPlayer;
this.playerDamage.put(name, count); this.playerDamage.put(name, count);
@@ -475,12 +479,18 @@ public class CombatCounter extends Plugin
// } // }
for (Integer i : new ArrayList<>(attackers.keySet())) for (Integer i : new ArrayList<>(attackers.keySet()))
{
if (i <= -1) if (i <= -1)
{
attackers.remove(i); attackers.remove(i);
}
}
if (attackers.isEmpty()) if (attackers.isEmpty())
{
this.npcDamageMap.remove(npc); this.npcDamageMap.remove(npc);
} }
}
this.playerDamage = sortByValue(this.playerDamage); this.playerDamage = sortByValue(this.playerDamage);
@@ -508,20 +518,26 @@ public class CombatCounter extends Plugin
NPCDamageCounter dc = new NPCDamageCounter(); NPCDamageCounter dc = new NPCDamageCounter();
if (this.npcDamageMap.containsKey(npc)) if (this.npcDamageMap.containsKey(npc))
{
dc = this.npcDamageMap.get(npc); dc = this.npcDamageMap.get(npc);
}
int delay = this.calculateBPDelay(distance); int delay = this.calculateBPDelay(distance);
List<Integer> counts = new ArrayList<>(); List<Integer> counts = new ArrayList<>();
counts.add(delay); counts.add(delay);
if (delay > 2) if (delay > 2)
{
counts.add(delay - 1); counts.add(delay - 1);
}
for (int tick : counts) for (int tick : counts)
{ {
List<String> attackers = new ArrayList<>(); List<String> attackers = new ArrayList<>();
if (dc.attackers.containsKey(tick)) if (dc.attackers.containsKey(tick))
{
attackers = dc.attackers.get(tick); attackers = dc.attackers.get(tick);
}
attackers.add(user); attackers.add(user);
dc.attackers.put(tick, attackers); dc.attackers.put(tick, attackers);
@@ -545,12 +561,16 @@ public class CombatCounter extends Plugin
Actor actor = event.getActor(); Actor actor = event.getActor();
if (!(actor instanceof NPC)) if (!(actor instanceof NPC))
{
return; return;
}
NPC npc = (NPC) actor; NPC npc = (NPC) actor;
if (!this.npcDamageMap.containsKey(npc)) if (!this.npcDamageMap.containsKey(npc))
{
return; return;
}
Hitsplat splat = event.getHitsplat(); Hitsplat splat = event.getHitsplat();
NPCDamageCounter dc = this.npcDamageMap.get(npc); NPCDamageCounter dc = this.npcDamageMap.get(npc);
@@ -586,6 +606,7 @@ public class CombatCounter extends Plugin
int distance = wpNPC.distanceTo(wpPlayer); int distance = wpNPC.distanceTo(wpPlayer);
if (size > 1) if (size > 1)
{
for (int x = 0; x < size; x++) for (int x = 0; x < size; x++)
{ {
for (int y = 0; y < size; y++) for (int y = 0; y < size; y++)
@@ -598,6 +619,8 @@ public class CombatCounter extends Plugin
} }
} }
} }
}
return distance; return distance;
} }
@@ -96,17 +96,18 @@ class CombatOverlay extends Overlay
return null; return null;
} }
for (String name : map.keySet()) for (Map.Entry<String, Long> counter : map.entrySet())
{ {
String name = counter.getKey();
if (client.getLocalPlayer().getName().contains(name)) if (client.getLocalPlayer().getName().contains(name))
{ {
tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getSelfColor()), ColorUtil.prependColorTag(Long.toString(map.get(name)), plugin.getSelfColor())); tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getSelfColor()), ColorUtil.prependColorTag(Long.toString(counter.getValue()), plugin.getSelfColor()));
} }
else else
{ {
tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getOtherColor()), ColorUtil.prependColorTag(Long.toString(map.get(name)), plugin.getOtherColor())); tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getOtherColor()), ColorUtil.prependColorTag(Long.toString(counter.getValue()), plugin.getOtherColor()));
} }
total += map.get(name); total += counter.getValue();
} }
if (!map.containsKey(local.getName())) if (!map.containsKey(local.getName()))
@@ -97,16 +97,16 @@ class DamageOverlay extends Overlay
return null; return null;
} }
for (String name : map.keySet()) for (Map.Entry<String, Double> damage : map.entrySet())
{ {
String val = String.format("%.1f", map.get(name)); String val = String.format("%.1f", damage.getValue());
if (client.getLocalPlayer().getName().contains(name)) if (client.getLocalPlayer().getName().contains(damage.getKey()))
{ {
tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getSelfColor()), ColorUtil.prependColorTag(val, plugin.getSelfColor())); tableComponent.addRow(ColorUtil.prependColorTag(damage.getKey(), plugin.getSelfColor()), ColorUtil.prependColorTag(val, plugin.getSelfColor()));
} }
else else
{ {
tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getOtherColor()), ColorUtil.prependColorTag(val, plugin.getOtherColor())); tableComponent.addRow(ColorUtil.prependColorTag(damage.getKey(), plugin.getOtherColor()), ColorUtil.prependColorTag(val, plugin.getOtherColor()));
} }
} }
@@ -10,9 +10,9 @@ import javax.inject.Singleton;
class NPCDamageCounter class NPCDamageCounter
{ {
Map<Integer, List<String>> attackers; final Map<Integer, List<String>> attackers;
List<Integer> damage; final List<Integer> damage;
NPCDamageCounter() NPCDamageCounter()
{ {
@@ -119,7 +119,7 @@ public class CombatLevelPlugin extends Plugin
if (widgetText.contains(".")) if (widgetText.contains("."))
{ {
combatLevelWidget.setText(widgetText.substring(0, widgetText.indexOf("."))); combatLevelWidget.setText(widgetText.substring(0, widgetText.indexOf('.')));
} }
} }
@@ -48,6 +48,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -992,7 +993,7 @@ public class ConfigPanel extends PluginPanel
if (e.getStateChange() == ItemEvent.SELECTED) if (e.getStateChange() == ItemEvent.SELECTED)
{ {
changeConfiguration(listItem, config, box, cd, cid); changeConfiguration(listItem, config, box, cd, cid);
box.setToolTipText(box.getSelectedItem().toString()); box.setToolTipText(Objects.requireNonNull(box.getSelectedItem()).toString());
} }
}); });
item.add(box, BorderLayout.EAST); item.add(box, BorderLayout.EAST);
@@ -1175,7 +1176,7 @@ public class ConfigPanel extends PluginPanel
else if (component instanceof JComboBox) else if (component instanceof JComboBox)
{ {
JComboBox jComboBox = (JComboBox) component; JComboBox jComboBox = (JComboBox) component;
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), ((Enum) jComboBox.getSelectedItem()).name()); configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), ((Enum) Objects.requireNonNull(jComboBox.getSelectedItem())).name());
for (ConfigItemDescriptor cid2 : cd.getItems()) for (ConfigItemDescriptor cid2 : cd.getItems())
{ {
@@ -10,8 +10,8 @@ import javax.swing.event.DocumentListener;
class DeferredDocumentChangedListener implements DocumentListener class DeferredDocumentChangedListener implements DocumentListener
{ {
private Timer timer; private final Timer timer;
private List<ChangeListener> listeners; private final List<ChangeListener> listeners;
DeferredDocumentChangedListener() DeferredDocumentChangedListener()
{ {
@@ -34,7 +34,7 @@ import net.runelite.client.config.Keybind;
import net.runelite.client.config.ModifierlessKeybind; import net.runelite.client.config.ModifierlessKeybind;
@Singleton @Singleton
public class HotkeyButton extends JButton class HotkeyButton extends JButton
{ {
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Keybind value; private Keybind value;
@@ -43,9 +43,7 @@ public class HotkeyButton extends JButton
{ {
setValue(value); setValue(value);
addActionListener(e -> addActionListener(e ->
{ setValue(Keybind.NOT_SET));
setValue(Keybind.NOT_SET);
});
addKeyListener(new KeyAdapter() addKeyListener(new KeyAdapter()
{ {
@Override @Override
@@ -63,7 +61,7 @@ public class HotkeyButton extends JButton
}); });
} }
public void setValue(Keybind value) private void setValue(Keybind value)
{ {
if (value == null) if (value == null)
{ {
@@ -62,7 +62,6 @@ public class PluginListItem extends JPanel
private static final ImageIcon OFF_STAR; private static final ImageIcon OFF_STAR;
private final ConfigPanel configPanel; private final ConfigPanel configPanel;
public final ConfigManager configManager;
@Getter @Getter
@Nullable @Nullable
@@ -144,7 +143,6 @@ public class PluginListItem extends JPanel
@Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags) @Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags)
{ {
this.configPanel = configPanel; this.configPanel = configPanel;
this.configManager = configManager;
this.plugin = plugin; this.plugin = plugin;
this.config = config; this.config = config;
this.configDescriptor = configDescriptor; this.configDescriptor = configDescriptor;
@@ -186,7 +184,7 @@ public class PluginListItem extends JPanel
buttonPanel.add(configButton); buttonPanel.add(configButton);
// add a listener to configButton only if there are config items to show // add a listener to configButton only if there are config items to show
if (config != null && !configDescriptor.getItems().stream().allMatch(item -> item.getItem().hidden())) if (configDescriptor != null && config != null && !configDescriptor.getItems().stream().allMatch(item -> item.getItem().hidden()))
{ {
configButton.addActionListener(e -> configButton.addActionListener(e ->
{ {
@@ -224,7 +224,7 @@ public class CorpPlugin extends Plugin
Actor source = interactingChanged.getSource(); Actor source = interactingChanged.getSource();
Actor target = interactingChanged.getTarget(); Actor target = interactingChanged.getTarget();
if (corp == null || target != corp) if (target != corp)
{ {
return; return;
} }
@@ -112,13 +112,10 @@ public class DeathIndicatorPlugin extends Plugin
return; return;
} }
if (config.showDeathHintArrow()) if (config.showDeathHintArrow() && !client.hasHintArrow())
{
if (!client.hasHintArrow())
{ {
client.setHintArrow(new WorldPoint(config.deathLocationX(), config.deathLocationY(), config.deathLocationPlane())); client.setHintArrow(new WorldPoint(config.deathLocationX(), config.deathLocationY(), config.deathLocationPlane()));
} }
}
if (config.showDeathOnWorldMap()) if (config.showDeathOnWorldMap())
{ {
@@ -53,8 +53,8 @@ public class DemonicGorillaOverlay extends Overlay
private static final int OVERLAY_ICON_DISTANCE = 50; private static final int OVERLAY_ICON_DISTANCE = 50;
private static final int OVERLAY_ICON_MARGIN = 8; private static final int OVERLAY_ICON_MARGIN = 8;
private Client client; private final Client client;
private DemonicGorillaPlugin plugin; private final DemonicGorillaPlugin plugin;
@Inject @Inject
private SkillIconManager iconManager; private SkillIconManager iconManager;
@@ -206,7 +206,8 @@ public class DemonicGorillaPlugin extends Plugin
} }
boolean correctPrayer = boolean correctPrayer =
target == null || // If player is out of memory, assume prayer was correct target == null || // If player is out of memory, assume prayer was correct
attackStyle == protectedStyle; (attackStyle != null &&
attackStyle.equals(protectedStyle));
if (attackStyle == DemonicGorilla.AttackStyle.BOULDER) if (attackStyle == DemonicGorilla.AttackStyle.BOULDER)
{ {
@@ -160,7 +160,7 @@ class DevToolsOverlay extends Overlay
for (Player p : players) for (Player p : players)
{ {
if (p != local) if (!p.equals(local))
{ {
String text = p.getName() + " (A: " + p.getAnimation() + ") (G: " + p.getSpotAnimation() + ")"; String text = p.getName() + " (A: " + p.getAnimation() + ") (G: " + p.getSpotAnimation() + ")";
OverlayUtil.renderActorOverlay(graphics, p, text, BLUE); OverlayUtil.renderActorOverlay(graphics, p, text, BLUE);
@@ -86,7 +86,6 @@ class VarInspector extends JFrame
private final static int MAX_LOG_ENTRIES = 10_000; private final static int MAX_LOG_ENTRIES = 10_000;
private final Client client; private final Client client;
private final DevToolsPlugin plugin;
private final EventBus eventBus; private final EventBus eventBus;
private final JPanel tracker = new JPanel(); private final JPanel tracker = new JPanel();
@@ -104,7 +103,6 @@ class VarInspector extends JFrame
{ {
this.eventBus = eventBus; this.eventBus = eventBus;
this.client = client; this.client = client;
this.plugin = plugin;
setTitle("RuneLite Var Inspector"); setTitle("RuneLite Var Inspector");
setIconImage(ClientUI.ICON); setIconImage(ClientUI.ICON);
@@ -63,7 +63,6 @@ class WidgetInspector extends JFrame
private final ClientThread clientThread; private final ClientThread clientThread;
private final DevToolsConfig config; private final DevToolsConfig config;
private final DevToolsOverlay overlay; private final DevToolsOverlay overlay;
private final DevToolsPlugin plugin;
private final JTree widgetTree; private final JTree widgetTree;
private final WidgetInfoTableModel infoTableModel; private final WidgetInfoTableModel infoTableModel;
@@ -86,7 +85,6 @@ class WidgetInspector extends JFrame
this.infoTableModel = infoTableModel; this.infoTableModel = infoTableModel;
this.config = config; this.config = config;
this.overlay = overlay; this.overlay = overlay;
this.plugin = plugin;
eventBus.register(this); eventBus.register(this);
@@ -301,7 +301,6 @@ enum DiscordGameEventType
this.details = training(skill); this.details = training(skill);
this.priority = priority; this.priority = priority;
this.imageKey = imageKeyOf(skill); this.imageKey = imageKeyOf(skill);
this.priority = priority;
this.shouldTimeout = true; this.shouldTimeout = true;
} }
@@ -86,8 +86,6 @@ import okhttp3.Response;
@Singleton @Singleton
public class DiscordPlugin extends Plugin public class DiscordPlugin extends Plugin
{ {
private static boolean discordEnabled = false;
@Inject @Inject
private Client client; private Client client;
@@ -112,7 +110,7 @@ public class DiscordPlugin extends Plugin
@Inject @Inject
private WSClient wsClient; private WSClient wsClient;
private Map<Skill, Integer> skillExp = new HashMap<>(); private final Map<Skill, Integer> skillExp = new HashMap<>();
private NavigationButton discordButton; private NavigationButton discordButton;
private boolean loginFlag; private boolean loginFlag;
@@ -159,7 +157,6 @@ public class DiscordPlugin extends Plugin
} }
wsClient.registerMessage(DiscordUserInfo.class); wsClient.registerMessage(DiscordUserInfo.class);
discordEnabled = true;
} }
@Override @Override
@@ -169,7 +166,6 @@ public class DiscordPlugin extends Plugin
discordState.reset(); discordState.reset();
partyService.changeParty(null); partyService.changeParty(null);
wsClient.unregisterMessage(DiscordUserInfo.class); wsClient.unregisterMessage(DiscordUserInfo.class);
discordEnabled = false;
} }
@Subscribe @Subscribe
@@ -342,9 +338,7 @@ public class DiscordPlugin extends Plugin
{ {
final PartyMember localMember = partyService.getLocalMember(); final PartyMember localMember = partyService.getLocalMember();
if (localMember != null) if (localMember != null && discordService.getCurrentUser() != null)
{
if (discordService.getCurrentUser() != null)
{ {
final DiscordUserInfo userInfo = new DiscordUserInfo( final DiscordUserInfo userInfo = new DiscordUserInfo(
discordService.getCurrentUser().userId, discordService.getCurrentUser().userId,
@@ -354,7 +348,6 @@ public class DiscordPlugin extends Plugin
wsClient.send(userInfo); wsClient.send(userInfo);
} }
} }
}
@Subscribe @Subscribe
public void onUserPart(final UserPart event) public void onUserPart(final UserPart event)
@@ -452,7 +445,7 @@ public class DiscordPlugin extends Plugin
return false; return false;
} }
public void updateConfig() private void updateConfig()
{ {
this.actionTimeout = config.actionTimeout(); this.actionTimeout = config.actionTimeout();
this.hideElapsedTime = config.hideElapsedTime(); this.hideElapsedTime = config.hideElapsedTime();
@@ -46,7 +46,7 @@ import static net.runelite.client.ws.PartyService.PARTY_MAX;
class DiscordState class DiscordState
{ {
@Data @Data
private class EventWithTime private static class EventWithTime
{ {
private final DiscordGameEventType type; private final DiscordGameEventType type;
private final Instant start; private final Instant start;
@@ -57,7 +57,7 @@ class DiscordState
private final List<EventWithTime> events = new ArrayList<>(); private final List<EventWithTime> events = new ArrayList<>();
private final DiscordService discordService; private final DiscordService discordService;
private final DiscordPlugin plugin; private final DiscordPlugin plugin;
private PartyService party; private final PartyService party;
private final RuneLiteProperties properties; private final RuneLiteProperties properties;
private DiscordPresence lastPresence; private DiscordPresence lastPresence;
@@ -49,14 +49,14 @@ import net.runelite.client.ui.PluginPanel;
@Slf4j @Slf4j
@Singleton @Singleton
public class EquipmentInspectorPanel extends PluginPanel class EquipmentInspectorPanel extends PluginPanel
{ {
private final static String NO_PLAYER_SELECTED = "No player selected"; private final static String NO_PLAYER_SELECTED = "No player selected";
private GridBagConstraints c; private final GridBagConstraints c;
private JPanel equipmentPanels; private final JPanel equipmentPanels;
private JPanel header; private final JPanel header;
private JLabel nameLabel; private final JLabel nameLabel;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@@ -306,7 +306,7 @@ public class EquipmentInspectorPlugin extends Plugin
} }
} }
public void updateConfig() private void updateConfig()
{ {
this.ShowValue = config.ShowValue(); this.ShowValue = config.ShowValue();
this.protecteditems = config.protecteditems(); this.protecteditems = config.protecteditems();
@@ -354,7 +354,7 @@ public class ExaminePlugin extends Plugin
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); log.error(e.toString());
} }
message message
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
@@ -103,7 +103,7 @@ public class XpDropPlugin extends Plugin
private boolean hasDropped = false; private boolean hasDropped = false;
private boolean correctPrayer; private boolean correctPrayer;
private Skill lastSkill = null; private Skill lastSkill = null;
private Map<Skill, Integer> previousSkillExpTable = new EnumMap<>(Skill.class); private final Map<Skill, Integer> previousSkillExpTable = new EnumMap<>(Skill.class);
private PrayerType currentTickPrayer; private PrayerType currentTickPrayer;
private XpDropConfig.DamageMode damageMode; private XpDropConfig.DamageMode damageMode;
@@ -401,12 +401,10 @@ public class XpDropPlugin extends Plugin
final String[] stringStack = client.getStringStack(); final String[] stringStack = client.getStringStack();
final int stringStackSize = client.getStringStackSize(); final int stringStackSize = client.getStringStackSize();
StringBuilder builder = new StringBuilder() String builder = stringStack[stringStackSize - 1] +
.append(stringStack[stringStackSize - 1]) ColorUtil.colorTag(this.damageColor) +
.append(ColorUtil.colorTag(this.damageColor)) " (" + damage + ")";
.append(" (").append(damage).append(")"); stringStack[stringStackSize - 1] = builder;
stringStack[stringStackSize - 1] = builder.toString();
} }
} }
@@ -252,11 +252,10 @@ public class FairyRingPlugin extends Plugin
return; return;
} }
if (codes != null) if (codes != null &&
{
// Check to make sure the list hasn't been rebuild since we were last her // Check to make sure the list hasn't been rebuild since we were last her
// Do this by making sure the list's dynamic children are the same as when we last saw them // Do this by making sure the list's dynamic children are the same as when we last saw them
if (codes.stream().noneMatch(w -> codes.stream().noneMatch(w ->
{ {
Widget codeWidget = w.getCode(); Widget codeWidget = w.getCode();
if (codeWidget == null) if (codeWidget == null)
@@ -268,7 +267,6 @@ public class FairyRingPlugin extends Plugin
{ {
codes = null; codes = null;
} }
}
if (codes == null) if (codes == null)
{ {
@@ -69,8 +69,8 @@ public class FeedPlugin extends Plugin
private FeedPanel feedPanel; private FeedPanel feedPanel;
private NavigationButton navButton; private NavigationButton navButton;
private FeedClient feedClient = new FeedClient(); private final FeedClient feedClient = new FeedClient();
private Supplier<FeedResult> feedSupplier = Suppliers.memoizeWithExpiration(() -> private final Supplier<FeedResult> feedSupplier = Suppliers.memoizeWithExpiration(() ->
{ {
try try
{ {
@@ -97,7 +97,7 @@ class FightCaveContainer
TZTOKJAD1(NpcID.TZTOKJAD, AttackStyle.UNKNOWN, ImmutableSet.of(AnimationID.TZTOK_JAD_MAGIC_ATTACK, AnimationID.TZTOK_JAD_RANGE_ATTACK, AnimationID.TZTOK_JAD_MELEE_ATTACK), 0), TZTOKJAD1(NpcID.TZTOKJAD, AttackStyle.UNKNOWN, ImmutableSet.of(AnimationID.TZTOK_JAD_MAGIC_ATTACK, AnimationID.TZTOK_JAD_RANGE_ATTACK, AnimationID.TZTOK_JAD_MELEE_ATTACK), 0),
TZTOKJAD2(NpcID.TZTOKJAD_6506, AttackStyle.UNKNOWN, ImmutableSet.of(AnimationID.TZTOK_JAD_MAGIC_ATTACK, AnimationID.TZTOK_JAD_RANGE_ATTACK, AnimationID.TZTOK_JAD_MELEE_ATTACK), 0); TZTOKJAD2(NpcID.TZTOKJAD_6506, AttackStyle.UNKNOWN, ImmutableSet.of(AnimationID.TZTOK_JAD_MAGIC_ATTACK, AnimationID.TZTOK_JAD_RANGE_ATTACK, AnimationID.TZTOK_JAD_MELEE_ATTACK), 0);
private static ImmutableMap<Integer, BossMonsters> idMap; private static final ImmutableMap<Integer, BossMonsters> idMap;
static static
{ {
@@ -48,9 +48,9 @@ import net.runelite.client.util.ImageUtil;
@Singleton @Singleton
public class FightCaveOverlay extends Overlay public class FightCaveOverlay extends Overlay
{ {
private FightCavePlugin plugin; private final FightCavePlugin plugin;
private Client client; private final Client client;
private SpriteManager spriteManager; private final SpriteManager spriteManager;
@Inject @Inject
FightCaveOverlay(final Client client, final FightCavePlugin plugin, final SpriteManager spriteManager) FightCaveOverlay(final Client client, final FightCavePlugin plugin, final SpriteManager spriteManager)
@@ -171,16 +171,13 @@ public class FightCavePlugin extends Plugin
{ {
updateConfig(); updateConfig();
if (client.getGameState() == GameState.LOGGED_IN) if (client.getGameState() == GameState.LOGGED_IN && regionCheck())
{
if (regionCheck())
{ {
validRegion = true; validRegion = true;
overlayManager.add(waveOverlay); overlayManager.add(waveOverlay);
overlayManager.add(fightCaveOverlay); overlayManager.add(fightCaveOverlay);
} }
} }
}
@Override @Override
public void shutDown() public void shutDown()
@@ -33,7 +33,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Line2D; import java.awt.geom.Line2D;
import java.util.ArrayList; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
@@ -65,7 +65,7 @@ public class FlexoOverlay extends Overlay
if (plugin.isDebugNPCs() || plugin.isDebugGroundItems() || plugin.isDebugPlayers()) if (plugin.isDebugNPCs() || plugin.isDebugGroundItems() || plugin.isDebugPlayers())
{ {
ArrayList<Rectangle> clickAreas = plugin.getClickAreas(); List<Rectangle> clickAreas = plugin.getClickAreas();
if (clickAreas != null) if (clickAreas != null)
{ {
for (Rectangle clickArea : clickAreas) for (Rectangle clickArea : clickAreas)
@@ -77,7 +77,7 @@ public class FlexoOverlay extends Overlay
} }
} }
ArrayList<Point> clickPoints = plugin.getClickPoints(); List<Point> clickPoints = plugin.getClickPoints();
if (clickPoints != null) if (clickPoints != null)
{ {
for (Point p : clickPoints) for (Point p : clickPoints)
@@ -134,9 +134,9 @@ public class FlexoPlugin extends Plugin
private int scalingFactor; private int scalingFactor;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private ArrayList<Rectangle> clickAreas = new ArrayList<>(); private List<Rectangle> clickAreas = new ArrayList<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private ArrayList<Point> clickPoints = new ArrayList<>(); private List<Point> clickPoints = new ArrayList<>();
@Subscribe @Subscribe
private void onConfigChanged(ConfigChanged event) private void onConfigChanged(ConfigChanged event)
@@ -172,9 +172,7 @@ public class FlexoPlugin extends Plugin
{ {
for (NPC npc : client.getNpcs()) for (NPC npc : client.getNpcs())
{ {
if (npc != null) if (npc != null && npc.getConvexHull() != null)
{
if (npc.getConvexHull() != null)
{ {
Rectangle r = FlexoMouse.getClickArea(npc.getConvexHull().getBounds()); Rectangle r = FlexoMouse.getClickArea(npc.getConvexHull().getBounds());
this.clickAreas.add(r); this.clickAreas.add(r);
@@ -184,7 +182,6 @@ public class FlexoPlugin extends Plugin
} }
} }
} }
}
if (this.debugPlayers) if (this.debugPlayers)
{ {
@@ -194,9 +191,7 @@ public class FlexoPlugin extends Plugin
{ {
for (Player player : client.getPlayers()) for (Player player : client.getPlayers())
{ {
if (player != null) if (player != null && player.getConvexHull() != null)
{
if (player.getConvexHull() != null)
{ {
Rectangle r = FlexoMouse.getClickArea(player.getConvexHull().getBounds()); Rectangle r = FlexoMouse.getClickArea(player.getConvexHull().getBounds());
this.clickAreas.add(r); this.clickAreas.add(r);
@@ -206,7 +201,6 @@ public class FlexoPlugin extends Plugin
} }
} }
} }
}
// Could still use some improvement // Could still use some improvement
if (this.debugGroundItems) if (this.debugGroundItems)
@@ -214,18 +208,14 @@ public class FlexoPlugin extends Plugin
Flexo.isStretched = client.isStretchedEnabled(); Flexo.isStretched = client.isStretchedEnabled();
Flexo.scale = this.scalingFactor; Flexo.scale = this.scalingFactor;
if (flexo != null) if (flexo != null && GroundItemsPlugin.getCollectedGroundItems() != null)
{
if (GroundItemsPlugin.getCollectedGroundItems() != null)
{ {
for (GroundItem gi : GroundItemsPlugin.getCollectedGroundItems().values()) for (GroundItem gi : GroundItemsPlugin.getCollectedGroundItems().values())
{ {
if (gi != null) if (gi != null)
{ {
LocalPoint lp = LocalPoint.fromWorld(client, gi.getLocation()); LocalPoint lp = LocalPoint.fromWorld(client, gi.getLocation());
if (lp != null) if (lp != null && Perspective.getCanvasTilePoly(client, lp) != null)
{
if (Perspective.getCanvasTilePoly(client, lp) != null)
{ {
Rectangle r1 = FlexoMouse.getClickArea(Perspective.getCanvasTilePoly(client, lp).getBounds()); Rectangle r1 = FlexoMouse.getClickArea(Perspective.getCanvasTilePoly(client, lp).getBounds());
Rectangle r2 = FlexoMouse.getClickArea(r1); Rectangle r2 = FlexoMouse.getClickArea(r1);
@@ -239,8 +229,6 @@ public class FlexoPlugin extends Plugin
} }
} }
} }
}
}
private void updateMouseMotionFactory() private void updateMouseMotionFactory()
{ {
@@ -54,7 +54,7 @@ public class FpsDrawListener implements Runnable
// Working set // Working set
private long lastMillis = 0; private long lastMillis = 0;
private long[] lastDelays = new long[SAMPLE_SIZE]; private final long[] lastDelays = new long[SAMPLE_SIZE];
private int lastDelayIndex = 0; private int lastDelayIndex = 0;
private long sleepDelay = 0; private long sleepDelay = 0;
@@ -55,7 +55,7 @@ public class FreezeTimersOverlay extends Overlay
private final BufferedImage FREEZE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "freeze.png"); private final BufferedImage FREEZE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "freeze.png");
private final BufferedImage TB_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "teleblock.png"); private final BufferedImage TB_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "teleblock.png");
private final BufferedImage VENG_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "veng.png"); private final BufferedImage VENG_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "veng.png");
private Timers timers; private final Timers timers;
@Inject @Inject
@@ -257,7 +257,7 @@ public class FreezeTimersOverlay extends Overlay
xOffset); xOffset);
} }
public void renderImageLocation(Graphics2D graphics, Point imgLoc, BufferedImage image) private void renderImageLocation(Graphics2D graphics, Point imgLoc, BufferedImage image)
{ {
int x = imgLoc.getX(); int x = imgLoc.getX();
int y = imgLoc.getY(); int y = imgLoc.getY();
@@ -162,7 +162,7 @@ public class FreezeTimersPlugin extends Plugin
this.remove(player); this.remove(player);
} }
public void remove(Actor actor) private void remove(Actor actor)
{ {
freezes.remove(actor.getName()); freezes.remove(actor.getName());
} }
@@ -24,6 +24,7 @@
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -34,14 +35,14 @@ import net.runelite.api.Player;
@Slf4j @Slf4j
@Singleton @Singleton
public class PrayerTracker class PrayerTracker
{ {
@Inject @Inject
private Client client; private Client client;
private HashMap<Actor, HashMap<String, Integer>> lastTick = new HashMap<>(); private final Map<Actor, HashMap<String, Integer>> lastTick = new HashMap<>();
private HashMap<Actor, HashMap<String, Integer>> newTick = new HashMap<>(); private final Map<Actor, HashMap<String, Integer>> newTick = new HashMap<>();
public void gameTick() public void gameTick()
{ {
@@ -24,15 +24,16 @@
package net.runelite.client.plugins.freezetimers; package net.runelite.client.plugins.freezetimers;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor; import net.runelite.api.Actor;
@Slf4j @Slf4j
@Singleton @Singleton
public class Timers class Timers
{ {
private HashMap<Actor, HashMap<TimerType, Long>> timerMap = new HashMap<>(); private final Map<Actor, HashMap<TimerType, Long>> timerMap = new HashMap<>();
void gameTick() void gameTick()
{ {
@@ -63,13 +63,13 @@ public class FriendTaggingPlugin extends Plugin
private static final String KEY_PREFIX = "tag_"; private static final String KEY_PREFIX = "tag_";
private static final String ADD_TAG = "Add Tag"; private static final String ADD_TAG = "Add Tag";
private static final String DELETE_TAG = "Delete Tag"; private static final String DELETE_TAG = "Delete Tag";
private WidgetMenuOption friendsTabMenuOption = new WidgetMenuOption("Copy to", "clipboard", private final WidgetMenuOption friendsTabMenuOption = new WidgetMenuOption("Copy to", "clipboard",
WidgetInfo.FIXED_VIEWPORT_FRIENDS_TAB); WidgetInfo.FIXED_VIEWPORT_FRIENDS_TAB);
private WidgetMenuOption ignoreTabMenuOption = new WidgetMenuOption("Copy to", "clipboard", private final WidgetMenuOption ignoreTabMenuOption = new WidgetMenuOption("Copy to", "clipboard",
WidgetInfo.FIXED_VIEWPORT_IGNORES_TAB); WidgetInfo.FIXED_VIEWPORT_IGNORES_TAB);
private WidgetMenuOption friendTabResizableOption = new WidgetMenuOption("Copy to", "clipboard", private final WidgetMenuOption friendTabResizableOption = new WidgetMenuOption("Copy to", "clipboard",
WidgetInfo.FIXED_VIEWPORT_FRIENDS_TAB); WidgetInfo.FIXED_VIEWPORT_FRIENDS_TAB);
private WidgetMenuOption ignoreTabResizableOption = new WidgetMenuOption("Copy to", "clipboard", private final WidgetMenuOption ignoreTabResizableOption = new WidgetMenuOption("Copy to", "clipboard",
WidgetInfo.FIXED_VIEWPORT_IGNORES_TAB); WidgetInfo.FIXED_VIEWPORT_IGNORES_TAB);
@Inject @Inject
@@ -841,7 +841,8 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
// Re-create fbo // Re-create fbo
if (lastStretchedCanvasWidth != stretchedCanvasWidth if (lastStretchedCanvasWidth != stretchedCanvasWidth
|| lastStretchedCanvasHeight != stretchedCanvasHeight || lastStretchedCanvasHeight != stretchedCanvasHeight
|| lastAntiAliasingMode != antiAliasingMode) || (lastAntiAliasingMode != null
&& !lastAntiAliasingMode.equals(antiAliasingMode)))
{ {
shutdownSceneFbo(); shutdownSceneFbo();
@@ -1012,7 +1013,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
final AnisotropicFilteringMode anisotropicFilteringMode = this.anisotropicFilteringMode; final AnisotropicFilteringMode anisotropicFilteringMode = this.anisotropicFilteringMode;
final boolean afEnabled = anisotropicFilteringMode != AnisotropicFilteringMode.DISABLED; final boolean afEnabled = anisotropicFilteringMode != AnisotropicFilteringMode.DISABLED;
if (lastAnisotropicFilteringMode != anisotropicFilteringMode) if (lastAnisotropicFilteringMode != null && !lastAnisotropicFilteringMode.equals(anisotropicFilteringMode))
{ {
if (afEnabled) if (afEnabled)
{ {
@@ -126,22 +126,16 @@ class SceneUploader
} }
GroundObject groundObject = tile.getGroundObject(); GroundObject groundObject = tile.getGroundObject();
if (groundObject != null) if (groundObject != null && groundObject.getRenderable() instanceof Model)
{
if (groundObject.getRenderable() instanceof Model)
{ {
((Model) groundObject.getRenderable()).setBufferOffset(-1); ((Model) groundObject.getRenderable()).setBufferOffset(-1);
} }
}
DecorativeObject decorativeObject = tile.getDecorativeObject(); DecorativeObject decorativeObject = tile.getDecorativeObject();
if (decorativeObject != null) if (decorativeObject != null && decorativeObject.getRenderable() instanceof Model)
{
if (decorativeObject.getRenderable() instanceof Model)
{ {
((Model) decorativeObject.getRenderable()).setBufferOffset(-1); ((Model) decorativeObject.getRenderable()).setBufferOffset(-1);
} }
}
GameObject[] gameObjects = tile.getGameObjects(); GameObject[] gameObjects = tile.getGameObjects();
for (GameObject gameObject : gameObjects) for (GameObject gameObject : gameObjects)
@@ -28,6 +28,7 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.util.Objects;
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.Client;
@@ -73,7 +74,7 @@ class GrotesqueGuardiansOverlay extends Overlay
// TODO: Awaiting GraphicsObjectDespawn event to be tracked to make this more efficient. // TODO: Awaiting GraphicsObjectDespawn event to be tracked to make this more efficient.
for (GraphicsObject graphicsObject : client.getGraphicsObjects()) for (GraphicsObject graphicsObject : client.getGraphicsObjects())
{ {
Color color = null; Color color;
if (graphicsObject.getId() >= GROTESQUE_GUARDIANS_LIGHTNING_START && graphicsObject.getId() <= GROTESQUE_GUARDIANS_LIGHTNING_END) if (graphicsObject.getId() >= GROTESQUE_GUARDIANS_LIGHTNING_START && graphicsObject.getId() <= GROTESQUE_GUARDIANS_LIGHTNING_END)
{ {
@@ -99,14 +100,12 @@ class GrotesqueGuardiansOverlay extends Overlay
{ {
OverlayUtil.renderPolygon(graphics, poly, color); OverlayUtil.renderPolygon(graphics, poly, color);
} }
if ((plugin.isInGargs()) && (plugin.isNeedingToRun())) if (plugin.isInGargs() && plugin.isNeedingToRun() && plugin.getDusk() != null && plugin.getDusk().getLocalLocation() != null)
{
if ((plugin.getDusk() != null) && (plugin.getDusk().getLocalLocation() != null))
{ {
TextComponent textComponent = new TextComponent(); TextComponent textComponent = new TextComponent();
LocalPoint duskPoint; LocalPoint duskPoint;
duskPoint = new LocalPoint(plugin.getDusk().getLocalLocation().getX() + 128 * (plugin.getDusk().getTransformedDefinition().getSize() - 1) / 2, plugin.getDusk().getLocalLocation().getY() + 128 * (plugin.getDusk().getTransformedDefinition().getSize() - 1) / 2); duskPoint = new LocalPoint(plugin.getDusk().getLocalLocation().getX() + 128 * (Objects.requireNonNull(plugin.getDusk().getTransformedDefinition()).getSize() - 1) / 2, plugin.getDusk().getLocalLocation().getY() + 128 * (plugin.getDusk().getTransformedDefinition().getSize() - 1) / 2);
net.runelite.api.Point duskLoc = Perspective.getCanvasTextLocation(client, graphics, duskPoint, "RUN AWAY", 500); net.runelite.api.Point duskLoc = Perspective.getCanvasTextLocation(client, graphics, duskPoint, "RUN AWAY", 500);
if (duskLoc != null) if (duskLoc != null)
{ {
@@ -117,7 +116,6 @@ class GrotesqueGuardiansOverlay extends Overlay
} }
} }
} }
}
return null; return null;
} }
} }
@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.Objects;
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.Client;
@@ -70,7 +71,7 @@ public class GrotesqueGuardiansPrayerOverlay extends Overlay
if ((plugin.isInGargs()) && (plugin.getPrayAgainst() != null) && (plugin.getDusk() != null)) if ((plugin.isInGargs()) && (plugin.getPrayAgainst() != null) && (plugin.getDusk() != null))
{ {
DuskAttack attack = plugin.getPrayAgainst(); DuskAttack attack = plugin.getPrayAgainst();
BufferedImage prayerImage = null; BufferedImage prayerImage;
prayerImage = getPrayerImage(attack); prayerImage = getPrayerImage(attack);
imagePanelComponent.setBackgroundColor(client imagePanelComponent.setBackgroundColor(client
.isPrayerActive(attack.getPrayer()) ? ComponentConstants.STANDARD_BACKGROUND_COLOR : NOT_ACTIVATED_BACKGROUND_COLOR); .isPrayerActive(attack.getPrayer()) ? ComponentConstants.STANDARD_BACKGROUND_COLOR : NOT_ACTIVATED_BACKGROUND_COLOR);
@@ -79,7 +80,7 @@ public class GrotesqueGuardiansPrayerOverlay extends Overlay
imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); imagePanelComponent.getChildren().add(new ImageComponent(prayerImage));
LocalPoint duskPoint = new LocalPoint(dusk.getLocalLocation().getX() + 128 * (dusk.getTransformedDefinition().getSize() - 1) / 2, dusk.getLocalLocation().getY() + 128 * (dusk.getTransformedDefinition().getSize() - 1) / 2); LocalPoint duskPoint = new LocalPoint(dusk.getLocalLocation().getX() + 128 * (Objects.requireNonNull(dusk.getTransformedDefinition()).getSize() - 1) / 2, dusk.getLocalLocation().getY() + 128 * (dusk.getTransformedDefinition().getSize() - 1) / 2);
net.runelite.api.Point duskLoc = Perspective.getCanvasImageLocation(client, duskPoint, prayerImage, 400); net.runelite.api.Point duskLoc = Perspective.getCanvasImageLocation(client, duskPoint, prayerImage, 400);
if (duskLoc != null) if (duskLoc != null)
{ {
@@ -36,7 +36,7 @@ import net.runelite.client.input.KeyListener;
import net.runelite.client.input.MouseAdapter; import net.runelite.client.input.MouseAdapter;
@Singleton @Singleton
public class GroundItemInputListener extends MouseAdapter implements KeyListener class GroundItemInputListener extends MouseAdapter implements KeyListener
{ {
private static final int HOTKEY = KeyEvent.VK_ALT; private static final int HOTKEY = KeyEvent.VK_ALT;
@@ -119,16 +119,13 @@ public class GroundItemInputListener extends MouseAdapter implements KeyListener
return e; return e;
} }
} }
else if (SwingUtilities.isRightMouseButton(e)) else if (SwingUtilities.isRightMouseButton(e) && plugin.getTextBoxBounds() != null && plugin.getTextBoxBounds().getKey().contains(mousePos))
{
if (plugin.getTextBoxBounds() != null && plugin.getTextBoxBounds().getKey().contains(mousePos))
{ {
plugin.updateList(plugin.getTextBoxBounds().getValue().getName(), true); plugin.updateList(plugin.getTextBoxBounds().getValue().getName(), true);
e.consume(); e.consume();
return e; return e;
} }
} }
}
return e; return e;
} }
@@ -352,7 +352,11 @@ public class GroundItemsOverlay extends Overlay
plugin.setHighlightBoxBounds(new SimpleEntry<>(itemHighlightBox, item)); plugin.setHighlightBoxBounds(new SimpleEntry<>(itemHighlightBox, item));
} }
boolean topItem = topGroundItem == item; boolean topItem = false;
if (topGroundItem != null)
{
topItem = topGroundItem.equals(item);
}
// Draw background if hovering // Draw background if hovering
if (topItem && (mouseInBox || mouseInHiddenBox || mouseInHighlightBox)) if (topItem && (mouseInBox || mouseInHiddenBox || mouseInHighlightBox))
@@ -273,7 +273,10 @@ public class GroundItemsPlugin extends Plugin
{ {
for (GroundItem item : collectedGroundItems.values()) for (GroundItem item : collectedGroundItems.values())
{ {
if (item.getTicks() == -1) continue; if (item.getTicks() == -1)
{
continue;
}
item.setTicks(item.getTicks() - 1); item.setTicks(item.getTicks() - 1);
} }
} }
@@ -488,23 +491,33 @@ public class GroundItemsPlugin extends Plugin
if (this.rightClickHidden) if (this.rightClickHidden)
{ {
if (aHidden && bMenuType == WALK) if (aHidden && bMenuType == WALK)
{
return -1; return -1;
}
if (bHidden && aMenuType == WALK) if (bHidden && aMenuType == WALK)
{
return 1; return 1;
} }
}
// sort hidden items below non-hidden items // sort hidden items below non-hidden items
if (aHidden && !bHidden && bMenuType != WALK) if (aHidden && !bHidden && bMenuType != WALK)
{
return -1; return -1;
}
if (bHidden && !aHidden && aMenuType != WALK) if (bHidden && !aHidden && aMenuType != WALK)
{
return 1; return 1;
}
// RS sorts by alch price by private, so no need to sort if config not set // RS sorts by alch price by private, so no need to sort if config not set
if (this.sortByGEPrice) if (this.sortByGEPrice)
{
return (getGePriceFromItemId(aId) * aQuantity) - (getGePriceFromItemId(bId) * bQuantity); return (getGePriceFromItemId(aId) * aQuantity) - (getGePriceFromItemId(bId) * bQuantity);
} }
} }
}
return 0; return 0;
}); });
@@ -738,11 +751,11 @@ public class GroundItemsPlugin extends Plugin
if (entries.length > 1) if (entries.length > 1)
{ {
MenuEntry[] newEntries = new MenuEntry[entries.length - 1]; MenuEntry[] newEntries = new MenuEntry[entries.length - 1];
for (int i = 0; i < entries.length; ++i) for (MenuEntry entry : entries)
{ {
if (!(entries[i].getOption().equals(option) && entries[i].getTarget().equals(target))) if (!(entry.getOption().equals(option) && entry.getTarget().equals(target)))
{ {
newEntries[j++] = entries[i]; newEntries[j++] = entry;
} }
} }
@@ -867,7 +880,9 @@ public class GroundItemsPlugin extends Plugin
{ {
// so that "Prayer Potion (4)" returns 1 instead of 4 and "Coins (25)" returns 25 instead of 1 // so that "Prayer Potion (4)" returns 1 instead of 4 and "Coins (25)" returns 25 instead of 1
if (!itemNameIncludesQuantity || matches >= 1) if (!itemNameIncludesQuantity || matches >= 1)
{
lastMatch = matcher.group(1); lastMatch = matcher.group(1);
}
matches++; matches++;
} }
@@ -129,15 +129,11 @@ public class HiscorePanel extends PluginPanel
private final List<JLabel> skillLabels = new ArrayList<>(); private final List<JLabel> skillLabels = new ArrayList<>();
private final JPanel statsPanel = new JPanel();
/* Container of all the selectable endpoints (ironman, deadman, etc) */ /* Container of all the selectable endpoints (ironman, deadman, etc) */
private final MaterialTabGroup tabGroup; private final MaterialTabGroup tabGroup;
private final HiscoreClient hiscoreClient = new HiscoreClient(); private final HiscoreClient hiscoreClient = new HiscoreClient();
private HiscoreResult result;
/* The currently selected endpoint */ /* The currently selected endpoint */
private HiscoreEndpoint selectedEndPoint; private HiscoreEndpoint selectedEndPoint;
@@ -247,6 +243,7 @@ public class HiscorePanel extends PluginPanel
// Panel that holds skill icons // Panel that holds skill icons
GridLayout stats = new GridLayout(8, 3); GridLayout stats = new GridLayout(8, 3);
JPanel statsPanel = new JPanel();
statsPanel.setLayout(stats); statsPanel.setLayout(stats);
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR); statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
statsPanel.setBorder(new EmptyBorder(5, 0, 5, 0)); statsPanel.setBorder(new EmptyBorder(5, 0, 5, 0));
@@ -371,6 +368,7 @@ public class HiscorePanel extends PluginPanel
selectedEndPoint = HiscoreEndpoint.NORMAL; selectedEndPoint = HiscoreEndpoint.NORMAL;
} }
HiscoreResult result;
try try
{ {
log.debug("Hiscore endpoint " + selectedEndPoint.name() + " selected"); log.debug("Hiscore endpoint " + selectedEndPoint.name() + " selected");
@@ -607,7 +605,11 @@ public class HiscorePanel extends PluginPanel
*/ */
if (SKILLS.contains(skill)) if (SKILLS.contains(skill))
{ {
long experience = result.getSkill(skill).getExperience(); long experience = 0;
if (skill != null)
{
experience = result.getSkill(skill).getExperience();
}
if (experience >= 0) if (experience >= 0)
{ {
int currentXp = (int) experience; int currentXp = (int) experience;
@@ -134,14 +134,6 @@ public class HunterPlugin extends Plugin
* ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------
*/ */
case ObjectID.DEADFALL: // Deadfall trap placed case ObjectID.DEADFALL: // Deadfall trap placed
if (localPlayer.getWorldLocation().distanceTo(trapLocation) <= 2)
{
log.debug("Trap placed by \"{}\" on {}", localPlayer.getName(), trapLocation);
traps.put(trapLocation, new HunterTrap(gameObject));
lastActionTime = Instant.now();
}
break;
case ObjectID.MONKEY_TRAP: // Maniacal monkey trap placed case ObjectID.MONKEY_TRAP: // Maniacal monkey trap placed
// If player is right next to "object" trap assume that player placed the trap // If player is right next to "object" trap assume that player placed the trap
if (localPlayer.getWorldLocation().distanceTo(trapLocation) <= 2) if (localPlayer.getWorldLocation().distanceTo(trapLocation) <= 2)
@@ -53,9 +53,7 @@ public class BabyHydraIndicatorOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (plugin.getHydra() != null) if (plugin.getHydra() != null && plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{
if (plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{ {
int val = plugin.getHydras().get(plugin.getHydra().getIndex()); int val = plugin.getHydras().get(plugin.getHydra().getIndex());
if (val != 0) if (val != 0)
@@ -65,7 +63,6 @@ public class BabyHydraIndicatorOverlay extends Overlay
return panelComponent.render(graphics); return panelComponent.render(graphics);
} }
} }
}
return null; return null;
} }
} }
@@ -65,9 +65,7 @@ public class BabyHydraOverlay extends Overlay
{ {
continue; continue;
} }
if (hydra.getName().equalsIgnoreCase("Hydra")) if (hydra.getName().equalsIgnoreCase("Hydra") && plugin.getHydras().containsKey(hydra.getIndex()))
{
if (plugin.getHydras().containsKey(hydra.getIndex()))
{ {
int val = plugin.getHydras().get(hydra.getIndex()); int val = plugin.getHydras().get(hydra.getIndex());
if (val != 0) if (val != 0)
@@ -112,7 +110,6 @@ public class BabyHydraOverlay extends Overlay
} }
} }
} }
}
} }
graphics.setFont(FontManager.getRunescapeFont()); graphics.setFont(FontManager.getRunescapeFont());
@@ -159,31 +159,22 @@ public class BabyHydraPlugin extends Plugin
public void onNpcSpawned(NpcSpawned event) public void onNpcSpawned(NpcSpawned event)
{ {
NPC hydra = event.getNpc(); NPC hydra = event.getNpc();
if (hydra.getCombatLevel() != 0 && hydra.getName() != null) if (hydra.getCombatLevel() != 0 && hydra.getName() != null && hydra.getName().equalsIgnoreCase("Hydra") && !hydras.containsKey(hydra.getIndex()))
{
if (hydra.getName().equalsIgnoreCase("Hydra"))
{
if (!hydras.containsKey(hydra.getIndex()))
{ {
hydras.put(hydra.getIndex(), 3); hydras.put(hydra.getIndex(), 3);
} }
} }
}
}
@Subscribe @Subscribe
public void onNpcDespawned(NpcDespawned event) public void onNpcDespawned(NpcDespawned event)
{ {
NPC hydra = event.getNpc(); NPC hydra = event.getNpc();
if (hydra.getCombatLevel() != 0 && hydra.getName() != null) if (hydra.getCombatLevel() != 0 && hydra.getName() != null && hydra.getName().equalsIgnoreCase("Hydra"))
{
if (hydra.getName().equalsIgnoreCase("Hydra"))
{ {
hydras.remove(hydra.getIndex()); hydras.remove(hydra.getIndex());
hydraattacks.remove(hydra.getIndex()); hydraattacks.remove(hydra.getIndex());
} }
} }
}
@Subscribe @Subscribe
public void onAnimationChanged(AnimationChanged event) public void onAnimationChanged(AnimationChanged event)
@@ -47,8 +47,8 @@ public class BabyHydraPrayOverlay extends Overlay
private final BabyHydraPlugin plugin; private final BabyHydraPlugin plugin;
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
private BufferedImage PRAY_MAGE; private BufferedImage prayMage;
private BufferedImage PRAY_RANGED; private BufferedImage prayRanged;
private final PanelComponent imagePanelComponent = new PanelComponent(); private final PanelComponent imagePanelComponent = new PanelComponent();
@Inject @Inject
@@ -69,23 +69,19 @@ public class BabyHydraPrayOverlay extends Overlay
@Override @Override
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (PRAY_MAGE == null) if (prayMage == null)
{ {
PRAY_MAGE = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0); prayMage = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MAGIC, 0);
} }
if (PRAY_RANGED == null) if (prayRanged == null)
{ {
PRAY_RANGED = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0); prayRanged = spriteManager.getSprite(SpriteID.PRAYER_PROTECT_FROM_MISSILES, 0);
} }
if (plugin.getHydra() != null) if (plugin.getHydra() != null && plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{
if (plugin.getHydras().containsKey(plugin.getHydra().getIndex()))
{ {
int val = plugin.getHydras().get(plugin.getHydra().getIndex()); int val = plugin.getHydras().get(plugin.getHydra().getIndex());
if (val != 0) if (val != 0 && plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
{
if (plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
{ {
int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex()); int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex());
if (attack == 8261) if (attack == 8261)
@@ -93,7 +89,7 @@ public class BabyHydraPrayOverlay extends Overlay
if (val == 3) if (val == 3)
{ {
imagePanelComponent.getChildren().clear(); imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_MAGE)); imagePanelComponent.getChildren().add(new ImageComponent(prayMage));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC) imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
? ComponentConstants.STANDARD_BACKGROUND_COLOR ? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR); : NOT_ACTIVATED_BACKGROUND_COLOR);
@@ -103,7 +99,7 @@ public class BabyHydraPrayOverlay extends Overlay
else else
{ {
imagePanelComponent.getChildren().clear(); imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_RANGED)); imagePanelComponent.getChildren().add(new ImageComponent(prayRanged));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES) imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
? ComponentConstants.STANDARD_BACKGROUND_COLOR ? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR); : NOT_ACTIVATED_BACKGROUND_COLOR);
@@ -116,7 +112,7 @@ public class BabyHydraPrayOverlay extends Overlay
if (val == 3) if (val == 3)
{ {
imagePanelComponent.getChildren().clear(); imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_RANGED)); imagePanelComponent.getChildren().add(new ImageComponent(prayRanged));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES) imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
? ComponentConstants.STANDARD_BACKGROUND_COLOR ? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR); : NOT_ACTIVATED_BACKGROUND_COLOR);
@@ -126,7 +122,7 @@ public class BabyHydraPrayOverlay extends Overlay
else else
{ {
imagePanelComponent.getChildren().clear(); imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_MAGE)); imagePanelComponent.getChildren().add(new ImageComponent(prayMage));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC) imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
? ComponentConstants.STANDARD_BACKGROUND_COLOR ? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR); : NOT_ACTIVATED_BACKGROUND_COLOR);
@@ -136,8 +132,6 @@ public class BabyHydraPrayOverlay extends Overlay
} }
} }
} }
}
}
return null; return null;
} }
} }
@@ -27,100 +27,18 @@ package net.runelite.client.plugins.idlenotifier;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.TrayIcon; import java.awt.TrayIcon;
//import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
//import javax.sound.sampled.LineUnavailableException;
//import javax.sound.sampled.UnsupportedAudioFileException;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Setter; import lombok.Setter;
import net.runelite.api.events.ConfigChanged;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.AnimationID; import net.runelite.api.AnimationID;
import static net.runelite.api.AnimationID.COOKING_FIRE; import static net.runelite.api.AnimationID.*;
import static net.runelite.api.AnimationID.COOKING_RANGE;
import static net.runelite.api.AnimationID.COOKING_WINE;
import static net.runelite.api.AnimationID.CRAFTING_BATTLESTAVES;
import static net.runelite.api.AnimationID.CRAFTING_GLASSBLOWING;
import static net.runelite.api.AnimationID.CRAFTING_LEATHER;
import static net.runelite.api.AnimationID.CRAFTING_POTTERS_WHEEL;
import static net.runelite.api.AnimationID.CRAFTING_POTTERY_OVEN;
import static net.runelite.api.AnimationID.CRAFTING_SPINNING;
import static net.runelite.api.AnimationID.DENSE_ESSENCE_CHIPPING;
import static net.runelite.api.AnimationID.DENSE_ESSENCE_CHISELING;
import static net.runelite.api.AnimationID.FARMING_MIX_ULTRACOMPOST;
import static net.runelite.api.AnimationID.FISHING_CRUSHING_INFERNAL_EELS;
import static net.runelite.api.AnimationID.FISHING_CUTTING_SACRED_EELS;
import static net.runelite.api.AnimationID.FLETCHING_BOW_CUTTING;
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAGIC_LONGBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAGIC_SHORTBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAPLE_LONGBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAPLE_SHORTBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_NORMAL_LONGBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_NORMAL_SHORTBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_OAK_LONGBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_OAK_SHORTBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_WILLOW_LONGBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_WILLOW_SHORTBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_YEW_LONGBOW;
import static net.runelite.api.AnimationID.FLETCHING_STRING_YEW_SHORTBOW;
import static net.runelite.api.AnimationID.GEM_CUTTING_AMETHYST;
import static net.runelite.api.AnimationID.GEM_CUTTING_DIAMOND;
import static net.runelite.api.AnimationID.GEM_CUTTING_EMERALD;
import static net.runelite.api.AnimationID.GEM_CUTTING_JADE;
import static net.runelite.api.AnimationID.GEM_CUTTING_OPAL;
import static net.runelite.api.AnimationID.GEM_CUTTING_REDTOPAZ;
import static net.runelite.api.AnimationID.GEM_CUTTING_RUBY;
import static net.runelite.api.AnimationID.GEM_CUTTING_SAPPHIRE;
import static net.runelite.api.AnimationID.HERBLORE_MAKE_TAR;
import static net.runelite.api.AnimationID.HERBLORE_PESTLE_AND_MORTAR;
import static net.runelite.api.AnimationID.HERBLORE_POTIONMAKING;
import static net.runelite.api.AnimationID.HOME_MAKE_TABLET;
import static net.runelite.api.AnimationID.IDLE;
import static net.runelite.api.AnimationID.MAGIC_CHARGING_ORBS;
import static net.runelite.api.AnimationID.MAGIC_ENCHANTING_AMULET_1;
import static net.runelite.api.AnimationID.MAGIC_ENCHANTING_AMULET_2;
import static net.runelite.api.AnimationID.MAGIC_ENCHANTING_AMULET_3;
import static net.runelite.api.AnimationID.MAGIC_ENCHANTING_JEWELRY;
import static net.runelite.api.AnimationID.MAGIC_LUNAR_PLANK_MAKE;
import static net.runelite.api.AnimationID.MAGIC_LUNAR_SHARED;
import static net.runelite.api.AnimationID.MAGIC_LUNAR_STRING_JEWELRY;
import static net.runelite.api.AnimationID.MAGIC_MAKE_TABLET;
import static net.runelite.api.AnimationID.MINING_3A_PICKAXE;
import static net.runelite.api.AnimationID.MINING_ADAMANT_PICKAXE;
import static net.runelite.api.AnimationID.MINING_BLACK_PICKAXE;
import static net.runelite.api.AnimationID.MINING_BRONZE_PICKAXE;
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE;
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE_ORN;
import static net.runelite.api.AnimationID.MINING_INFERNAL_PICKAXE;
import static net.runelite.api.AnimationID.MINING_IRON_PICKAXE;
import static net.runelite.api.AnimationID.MINING_MITHRIL_PICKAXE;
import static net.runelite.api.AnimationID.MINING_RUNE_PICKAXE;
import static net.runelite.api.AnimationID.MINING_STEEL_PICKAXE;
import static net.runelite.api.AnimationID.PISCARILIUS_CRANE_REPAIR;
import static net.runelite.api.AnimationID.SAND_COLLECTION;
import static net.runelite.api.AnimationID.SMITHING_ANVIL;
import static net.runelite.api.AnimationID.SMITHING_CANNONBALL;
import static net.runelite.api.AnimationID.SMITHING_SMELTING;
import static net.runelite.api.AnimationID.USING_GILDED_ALTAR;
import static net.runelite.api.AnimationID.WOODCUTTING_3A_AXE;
import static net.runelite.api.AnimationID.WOODCUTTING_ADAMANT;
import static net.runelite.api.AnimationID.WOODCUTTING_BLACK;
import static net.runelite.api.AnimationID.WOODCUTTING_BRONZE;
import static net.runelite.api.AnimationID.WOODCUTTING_DRAGON;
import static net.runelite.api.AnimationID.WOODCUTTING_INFERNAL;
import static net.runelite.api.AnimationID.WOODCUTTING_IRON;
import static net.runelite.api.AnimationID.WOODCUTTING_MITHRIL;
import static net.runelite.api.AnimationID.WOODCUTTING_RUNE;
import static net.runelite.api.AnimationID.WOODCUTTING_STEEL;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.api.GameState; import net.runelite.api.GameState;
@@ -135,12 +53,13 @@ import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.WorldType; import net.runelite.api.WorldType;
import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.InteractingChanged; import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.PlayerSpawned; import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
@@ -150,6 +69,10 @@ import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.PvPUtil; import net.runelite.client.util.PvPUtil;
//import java.io.IOException;
//import javax.sound.sampled.LineUnavailableException;
//import javax.sound.sampled.UnsupportedAudioFileException;
@PluginDescriptor( @PluginDescriptor(
name = "Idle Notifier", name = "Idle Notifier",
description = "Send a notification when going idle, or when HP/Prayer reaches a threshold", description = "Send a notification when going idle, or when HP/Prayer reaches a threshold",
@@ -158,8 +81,6 @@ import net.runelite.client.util.PvPUtil;
@Singleton @Singleton
public class IdleNotifierPlugin extends Plugin public class IdleNotifierPlugin extends Plugin
{ {
private static final Logger logger = LoggerFactory.getLogger(IdleNotifierPlugin.class);
// This must be more than 500 client ticks (10 seconds) before you get AFK kicked // This must be more than 500 client ticks (10 seconds) before you get AFK kicked
private static final int LOGOUT_WARNING_MILLIS = (4 * 60 + 40) * 1000; // 4 minutes and 40 seconds private static final int LOGOUT_WARNING_MILLIS = (4 * 60 + 40) * 1000; // 4 minutes and 40 seconds
private static final int COMBAT_WARNING_MILLIS = 19 * 60 * 1000; // 19 minutes private static final int COMBAT_WARNING_MILLIS = 19 * 60 * 1000; // 19 minutes
@@ -362,13 +283,8 @@ public class IdleNotifierPlugin extends Plugin
private void onPlayerSpawned(PlayerSpawned event) private void onPlayerSpawned(PlayerSpawned event)
{ {
final Player p = event.getPlayer(); final Player p = event.getPlayer();
if (this.notifyPkers) if (this.notifyPkers && p != null && p != client.getLocalPlayer()
{ && PvPUtil.isAttackable(client, p) && !client.isFriended(p.getName(), false)
if (p != null)
{
if (p != client.getLocalPlayer())
{
if (PvPUtil.isAttackable(client, p) && !client.isFriended(p.getName(), false)
&& !client.isClanMember(p.getName())) && !client.isClanMember(p.getName()))
{ {
String playerName = p.getName(); String playerName = p.getName();
@@ -377,9 +293,6 @@ public class IdleNotifierPlugin extends Plugin
" appeared!", TrayIcon.MessageType.WARNING); " appeared!", TrayIcon.MessageType.WARNING);
} }
} }
}
}
}
@Subscribe @Subscribe
public void onInteractingChanged(InteractingChanged event) public void onInteractingChanged(InteractingChanged event)
@@ -29,7 +29,9 @@ public class ImplingCounterOverlay extends Overlay
public Dimension render(Graphics2D graphics) public Dimension render(Graphics2D graphics)
{ {
if (!plugin.isShowSpawn() || plugin.getImplings().isEmpty()) if (!plugin.isShowSpawn() || plugin.getImplings().isEmpty())
{
return null; return null;
}
panelComponent.getChildren().clear(); panelComponent.getChildren().clear();
@@ -41,7 +41,7 @@ public class InfernoNPC
RANDOM("Random", Color.ORANGE); RANDOM("Random", Color.ORANGE);
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private String name = ""; private String name;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Color color; private Color color;
@@ -88,7 +88,7 @@ public class InfernoOverlay extends Overlay
} }
// renders text location // renders text location
public static void renderTextLocation(Graphics2D graphics, InfernoNPC actor, String text, Color color) private static void renderTextLocation(Graphics2D graphics, InfernoNPC actor, String text, Color color)
{ {
graphics.setFont(new Font("Arial", Font.BOLD, 15)); graphics.setFont(new Font("Arial", Font.BOLD, 15));
Point textLocation = actor.getNpc().getCanvasTextLocation(graphics, text, actor.textLocHeight + 40); Point textLocation = actor.getNpc().getCanvasTextLocation(graphics, text, actor.textLocHeight + 40);
@@ -118,7 +118,7 @@ public class InfernoPlugin extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private int currentWaveNumber; private int currentWaveNumber;
private List<Actor> waveMonsters; private final List<Actor> waveMonsters;
public InfernoPlugin() public InfernoPlugin()
{ {

Some files were not shown because too many files have changed in this diff Show More