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

View File

@@ -53,10 +53,7 @@ public class ConfigDescriptor
Collection<ConfigItemDescriptor> allItems = new ArrayList<>();
for (ConfigItemsGroup g : itemGroups)
{
for (ConfigItemDescriptor item : g.getItems())
{
allItems.add(item);
}
allItems.addAll(g.getItems());
}
return allItems;
}

View File

@@ -81,7 +81,6 @@ public class ConfigManager
@Inject
EventBus eventBus;
private final ScheduledExecutorService executor;
private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this);
private final Properties properties = new Properties();
private final Map<String, Object> configObjectCache = new HashMap<>();
@@ -90,9 +89,8 @@ public class ConfigManager
@Inject
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()
@@ -245,12 +243,10 @@ public class ConfigManager
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
}, handler);
return t;
}
public List<String> getConfigurationKeys(String prefix)

View File

@@ -60,7 +60,7 @@ public class Keybind
private final int keyCode;
private final int modifiers;
protected Keybind(int keyCode, int modifiers, boolean ignoreModifiers)
Keybind(int keyCode, int modifiers, boolean ignoreModifiers)
{
modifiers &= KEYBOARD_MODIFIER_MASK;
@@ -108,7 +108,7 @@ public class Keybind
return matches(e, false);
}
protected boolean matches(KeyEvent e, boolean ignoreModifiers)
boolean matches(KeyEvent e, boolean ignoreModifiers)
{
if (NOT_SET.equals(this))
{
@@ -177,7 +177,7 @@ public class Keybind
return mod;
}
public static String getModifiersExText(int modifiers)
private static String getModifiersExText(int modifiers)
{
StringBuilder buf = new StringBuilder();
if ((modifiers & InputEvent.META_DOWN_MASK) != 0)

View File

@@ -124,10 +124,6 @@ public class DiaryRequirementsPlugin extends Plugin
}
Map<String, String> skillRequirements = buildRequirements(requirements.getRequirements());
if (skillRequirements == null)
{
return;
}
int offset = 0;
String taskBuffer = "";

View File

@@ -39,9 +39,9 @@ class AmmoCounter extends Counter
{
@Getter(AccessLevel.PACKAGE)
private int itemID;
private String name;
private int total;
private Instant time;
private final String name;
private final int total;
private final Instant time;
private BigDecimal ammoPerHour;
AmmoCounter(Plugin plugin, int itemID, int count, String name, BufferedImage image)

View File

@@ -144,7 +144,7 @@ public class AntiDragPlugin extends Plugin
}
}
public void updateConfig()
private void updateConfig()
{
this.alwaysOn = config.alwaysOn();
this.keybind = config.keybind();
@@ -160,13 +160,10 @@ public class AntiDragPlugin extends Plugin
@Subscribe
public void onFocusChanged(FocusChanged focusChanged)
{
if (!this.alwaysOn)
if (!this.alwaysOn && !focusChanged.isFocused() && this.reqfocus)
{
if (!focusChanged.isFocused() && this.reqfocus)
{
client.setInventoryDragDelay(DEFAULT_DELAY);
overlayManager.remove(overlay);
}
client.setInventoryDragDelay(DEFAULT_DELAY);
overlayManager.remove(overlay);
}
}

View File

@@ -157,14 +157,12 @@ public class AoeWarningOverlay extends Overlay
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), outlineAlpha), true));
graphics.drawPolygon(tilePoly);
}
if (plugin.isTickTimers())
if (plugin.isTickTimers() && tickProgress >= 0)
{
if (tickProgress >= 0)
{
OverlayUtil.renderTextLocation(graphics, Integer.toString(tickProgress), plugin.getTextSize(),
plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0);
}
OverlayUtil.renderTextLocation(graphics, Integer.toString(tickProgress), plugin.getTextSize(),
plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0);
}
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true));
graphics.fillPolygon(tilePoly);
}

View File

@@ -450,7 +450,7 @@ public class AoeWarningPlugin extends Plugin
return false;
}
public void updateConfig()
private void updateConfig()
{
this.aoeNotifyAll = config.aoeNotifyAll();
this.overlayColor = config.overlayColor();

View File

@@ -269,7 +269,7 @@ public class AttackStylesPlugin extends Plugin
}
}
public void updateConfig()
private void updateConfig()
{
this.alwaysShowStyle = config.alwaysShowStyle();
this.warnForDefence = config.warnForDefence();
@@ -320,10 +320,10 @@ public class AttackStylesPlugin extends Plugin
{
if (warnedSkills.contains(skill))
{
if (weaponSwitch)
{
// TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change
}
// if (weaponSwitch)
// {
// // TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change
// }
warnedSkillSelected = true;
break;
}

View File

@@ -203,7 +203,7 @@ public class BankPlugin extends Plugin
updateConfig();
}
public void updateConfig()
private void updateConfig()
{
this.showGE = config.showGE();
this.showHA = config.showHA();

View File

@@ -246,10 +246,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
intStack[intStackSize - 1] = 0;
break;
case "hideLine":
// hide the widget for the line separator
intStack[intStackSize - 1] = 1;
break;
case "hideTabText":
// hide the widget for the line separator
// hide the widget for the "Tab x" text
intStack[intStackSize - 1] = 1;
break;

View File

@@ -66,7 +66,7 @@ public class TagManager
this.clueScrollService = clueScrollService;
}
String getTagString(int itemId, boolean variation)
private String getTagString(int itemId, boolean variation)
{
itemId = getItemId(itemId, variation);

View File

@@ -53,8 +53,8 @@ import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition;
import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.Point;
@@ -579,11 +579,14 @@ public class TabInterface
if (event.getOption().startsWith(CHANGE_ICON + " ("))
{
ItemDefinition item = getItem(event.getActionParam0());
int itemId = itemManager.canonicalize(item.getId());
iconToSet.setIconItemId(itemId);
iconToSet.getIcon().setItemId(itemId);
tabManager.setIcon(iconToSet.getTag(), itemId + "");
event.consume();
if (item != null)
{
int itemId = itemManager.canonicalize(item.getId());
iconToSet.setIconItemId(itemId);
iconToSet.getIcon().setItemId(itemId);
tabManager.setIcon(iconToSet.getTag(), itemId + "");
event.consume();
}
}
// Reset icon selection even when we do not clicked item with icon
@@ -613,9 +616,13 @@ public class TabInterface
// Add "remove" menu entry to all items in bank while tab is selected
event.consume();
final ItemDefinition item = getItem(event.getActionParam0());
final int itemId = item.getId();
tagManager.removeTag(itemId, activeTab.getTag());
bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true);
final int itemId;
if (item != null)
{
itemId = item.getId();
tagManager.removeTag(itemId, activeTab.getTag());
bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true);
}
}
else if (event.getMenuAction() == MenuAction.RUNELITE
&& ((event.getActionParam1() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getOption().equals(TAG_INVENTORY))
@@ -669,15 +676,11 @@ public class TabInterface
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.save();
updateTabs();
}
tabManager.move(draggedWidget.getName(), draggedOn.getName());
tabManager.save();
updateTabs();
}
}
else if (draggedWidget.getItemId() > 0)
@@ -1010,8 +1013,17 @@ public class TabInterface
private ItemDefinition getItem(int idx)
{
ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
Item item = bankContainer.getItems()[idx];
return itemManager.getItemDefinition(item.getId());
Item item = null;
if (bankContainer != null)
{
item = bankContainer.getItems()[idx];
}
if (item != null)
{
return itemManager.getItemDefinition(item.getId());
}
return null;
}
private void openTag(final String tag)

View File

@@ -26,10 +26,14 @@
*/
package net.runelite.client.plugins.banlist;
import com.google.common.base.Splitter;
import com.google.inject.Provides;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
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.WidgetLoaded;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.TRADING_SCREEN;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatColorType;
@@ -84,10 +89,10 @@ public class BanListPlugin extends Plugin
@Inject
private ChatMessageManager chatMessageManager;
private ArrayList<String> wdrScamArrayList = new ArrayList<>();
private ArrayList<String> wdrToxicArrayList = new ArrayList<>();
private ArrayList<String> runeWatchArrayList = new ArrayList<>();
private ArrayList<String> manualBans = new ArrayList<>();
private final Set<String> wdrScamSet = new HashSet<>();
private final Set<String> wdrToxicSet = new HashSet<>();
private final Set<String> runeWatchSet = new HashSet<>();
private final Set<String> manualBans = new HashSet<>();
@Provides
BanListConfig getConfig(ConfigManager configManager)
@@ -105,38 +110,46 @@ public class BanListPlugin extends Plugin
protected void startUp() throws Exception
{
updateConfig();
manualBans.addAll(Text.fromCSV(config.getBannedPlayers()));
List<String> bannedPlayers = Splitter
.on(",")
.trimResults()
.omitEmptyStrings()
.splitToList(config.getBannedPlayers());
manualBans.addAll(bannedPlayers);
fetchFromWebsites();
}
@Override
protected void shutDown() throws Exception
{
wdrScamArrayList.clear();
wdrToxicArrayList.clear();
runeWatchArrayList.clear();
wdrScamSet.clear();
wdrToxicSet.clear();
runeWatchSet.clear();
manualBans.clear();
}
@Subscribe
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(manual));
}
manualBans.add(Text.standardize(bannedPlayer));
}
}
}
}
public void updateConfig()
private void updateConfig()
{
this.enableWDR = config.enableWDR();
this.enableRuneWatch = config.enableRuneWatch();
@@ -173,12 +186,14 @@ public class BanListPlugin extends Plugin
public void onClanMemberJoined(ClanMemberJoined event)
{
ClanMember member = event.getMember();
ListType scamList = checkScamList(Text.standardize(member.getUsername()));
ListType toxicList = checkToxicList(Text.standardize(member.getUsername()));
String memberUsername = Text.standardize(member.getUsername().toLowerCase());
ListType scamList = checkScamList(memberUsername);
ListType toxicList = checkToxicList(memberUsername);
if (scamList != null)
{
sendWarning(Text.standardize(member.getUsername()), scamList);
sendWarning(memberUsername, scamList);
if (this.highlightInClan)
{
highlightRedInCC();
@@ -187,7 +202,7 @@ public class BanListPlugin extends Plugin
if (toxicList != null)
{
sendWarning(Text.standardize(member.getUsername()), toxicList);
sendWarning(memberUsername, toxicList);
if (this.highlightInClan)
{
highlightRedInCC();
@@ -201,24 +216,21 @@ public class BanListPlugin extends Plugin
@Subscribe
public void onWidgetLoaded(WidgetLoaded widgetLoaded)
{
if (this.highlightInTrade)
{
if (widgetLoaded.getGroupId() == 335)
{ //if trading window was loaded
clientThread.invokeLater(() ->
if (this.highlightInTrade && widgetLoaded.getGroupId() == TRADING_SCREEN)
{ //if trading window was loaded
clientThread.invokeLater(() ->
{
Widget tradingWith = client.getWidget(335, 31);
String name = tradingWith.getText().replaceAll("Trading With: ", "").toLowerCase();
if (checkScamList(name) != null)
{
Widget tradingWith = client.getWidget(335, 31);
String name = tradingWith.getText().replaceAll("Trading With: ", "");
if (checkScamList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>"));
}
if (checkToxicList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff6400>" + name + " (Toxic)" + "</col>"));
}
});
}
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>"));
}
if (checkToxicList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff6400>" + name + " (Toxic)" + "</col>"));
}
});
}
}
@@ -227,28 +239,19 @@ public class BanListPlugin extends Plugin
*/
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;
@@ -257,12 +260,9 @@ public class BanListPlugin extends Plugin
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;
@@ -354,9 +354,9 @@ public class BanListPlugin extends Plugin
ArrayList<String> wdrList = new ArrayList<>(Arrays.asList(text.split(",")));
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"))
{
x = x.substring(x.indexOf("title"), x.indexOf(">"));
x = x.substring(x.indexOf("=") + 2, x.length() - 1);
runeWatchArrayList.add(Text.standardize(x));
x = x.substring(x.indexOf("title"), x.indexOf('>'));
x = x.substring(x.indexOf('=') + 2, x.length() - 1);
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> 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);
for (Widget widgetChild : widget.getDynamicChildren())
{
ListType scamList = checkScamList(widgetChild.getText());
ListType toxicList = checkToxicList(widgetChild.getText());
ListType scamList = checkScamList(widgetChild.getText().toLowerCase());
ListType toxicList = checkToxicList(widgetChild.getText().toLowerCase());
if (scamList != null)
{

View File

@@ -26,6 +26,7 @@
package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.Sets;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@@ -41,7 +42,7 @@ class BarbarianAssaultMenu
{
private final MenuManager menuManager;
private final BarbarianAssaultPlugin game;
private final ArrayList<ComparableEntry> tracker = new ArrayList<>();
private final List<ComparableEntry> tracker = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean hornUpdated = false;
@@ -58,7 +59,7 @@ class BarbarianAssaultMenu
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
// medic will be added to the menu if it wasn't there before

View File

@@ -29,7 +29,6 @@ package net.runelite.client.plugins.barbarianassault;
import com.google.common.collect.ImmutableList;
import com.google.inject.Provides;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.KeyEvent;
@@ -42,12 +41,10 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
@@ -186,16 +183,16 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private Font font = null;
@Getter
private final HashMap<WorldPoint, Integer> redEggs = new HashMap<>();
private final Map<WorldPoint, Integer> redEggs = new HashMap<>();
@Getter
private final HashMap<WorldPoint, Integer> greenEggs = new HashMap<>();
private final Map<WorldPoint, Integer> greenEggs = new HashMap<>();
@Getter
private final HashMap<WorldPoint, Integer> blueEggs = new HashMap<>();
private final Map<WorldPoint, Integer> blueEggs = new HashMap<>();
@Getter
private final HashMap<WorldPoint, Integer> yellowEggs = new HashMap<>();
private final Map<WorldPoint, Integer> yellowEggs = new HashMap<>();
@Getter
private final Map<Integer, Healer> healers = new HashMap<>();
@@ -206,7 +203,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
@Getter
private String lastListenText = null;
private String lastClickedTell = null;
// private String lastClickedTell = null;
private int lastCallColor = -1;
@@ -216,7 +213,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
private int tickNum = 0;
private int gameTick = -1;
// private int gameTick = -1;
private int inGameBit = 0;
@@ -237,9 +234,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
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;
@@ -341,7 +338,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
controlDown = false;
resetWave();
wave = null;
gameTick = client.getTickCount();
// gameTick = client.getTickCount();
menu.disableSwaps(true);
menu.clearHiddenMenus();
}
@@ -452,7 +449,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
}
}
public void updateConfig()
private void updateConfig()
{
this.swapLadder = config.swapLadder();
this.showTimer = config.showTimer();
@@ -648,7 +645,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
return;
}
HashMap<WorldPoint, Integer> eggMap = getEggMap(itemSpawned.getItem().getId());
Map<WorldPoint, Integer> eggMap = getEggMap(itemSpawned.getItem().getId());
if (eggMap != null)
{
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,
// 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)
{
WorldPoint worldPoint = itemDespawned.getTile().getWorldLocation();
@@ -760,12 +757,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
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));
}
}
@@ -1160,16 +1154,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
String target = Text.removeTags(event.getTarget()).toLowerCase();
if (getRole() == Role.HEALER)
if (getRole() == Role.HEALER && (target.startsWith("poisoned meat -> penance healer")
|| target.startsWith("poisoned tofu -> penance healer")
|| target.startsWith("poisoned worms -> penance healer")))
{
if (target.startsWith("poisoned meat -> penance healer")
|| target.startsWith("poisoned tofu -> penance healer")
|| target.startsWith("poisoned worms -> penance healer"))
{
lastHealerPoisoned = event.getIdentifier();
poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->");
return;
}
lastHealerPoisoned = event.getIdentifier();
poisonUsed = StringUtils.substringBefore(target.replace("oned", "."), " ->");
}
// INW
@@ -1206,14 +1196,11 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
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.setFoodRemaining(healer.getFoodRemaining() - 1);
healer.setTimeLastPoisoned(Instant.now());
}
Healer healer = healers.get(lastInteracted);
healer.setFoodRemaining(healer.getFoodRemaining() - 1);
healer.setTimeLastPoisoned(Instant.now());
}
lastInteracted = -1;
@@ -1263,7 +1250,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
lastListenText = null;
lastCallText = null;
lastCallColor = -1;
lastClickedTell = null;
// lastClickedTell = null;
}
else
{
@@ -1385,12 +1372,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
if (newCallColor == COLOR_CALL_CALLED)
{
lastCallColor = COLOR_CALL_CALLED;
lastClickedTell = lastCallText;
// lastClickedTell = lastCallText;
}
else if (callTimer == null)
{
lastCallColor = COLOR_CALL_UPDATED;
lastClickedTell = null;
// lastClickedTell = null;
}
if (callWidget != null)
@@ -1603,7 +1590,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
yellowEggs.clear();
}
private HashMap<WorldPoint, Integer> getEggMap(int itemID)
private Map<WorldPoint, Integer> getEggMap(int itemID)
{
switch (itemID)
{

View File

@@ -28,6 +28,7 @@ package net.runelite.client.plugins.barbarianassault;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.events.ChatMessage;
@@ -41,7 +42,7 @@ public class Scorecard
private BarbarianAssaultPlugin game;
@Getter(AccessLevel.NONE)
private ArrayList<Wave> waves = new ArrayList<>();
private List<Wave> waves = new ArrayList<>();
private String[] totalDescriptions = {
"A: ",
"; D: ",
@@ -67,13 +68,10 @@ public class Scorecard
@Subscribe
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];
totalAmounts = new int[6];
}
totalPoints = new int[6];
totalAmounts = new int[6];
}
}

View File

@@ -207,7 +207,7 @@ public class BarrowsPlugin extends Plugin
}
}
public void updateConfig()
private void updateConfig()
{
this.showMinimap = config.showMinimap();
this.showBrotherLoc = config.showBrotherLoc();
@@ -289,19 +289,16 @@ public class BarrowsPlugin extends Plugin
ladders.clear();
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();
if (wasInCrypt && !isInCrypt)
{
boolean isInCrypt = isInCrypt();
if (wasInCrypt && !isInCrypt)
{
stopPrayerDrainTimer();
}
else if (!wasInCrypt && isInCrypt)
{
startPrayerDrainTimer();
}
stopPrayerDrainTimer();
}
else if (!wasInCrypt && isInCrypt)
{
startPrayerDrainTimer();
}
}
}

View File

@@ -117,12 +117,9 @@ public class BlackjackPlugin extends Plugin
@Subscribe
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);
}
}
}

View File

@@ -210,7 +210,7 @@ public class BlastFurnacePlugin extends Plugin
}
}
public void updateConfig()
private void updateConfig()
{
this.showBarDispenser = config.showBarDispenser();
this.showConveyorBelt = config.showConveyorBelt();

View File

@@ -106,7 +106,7 @@ public class BoostsPlugin extends Plugin
private int lastChangeUp = -1;
private boolean preserveBeenActive = false;
private long lastTickMillis;
private List<String> boostedSkillsChanged = new ArrayList<>();
private final List<String> boostedSkillsChanged = new ArrayList<>();
private boolean enableSkill;
@Getter(AccessLevel.PACKAGE)

View File

@@ -29,7 +29,7 @@ import java.awt.image.BufferedImage;
import net.runelite.client.ui.overlay.infobox.InfoBox;
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
public class StatChangeIndicator extends InfoBox
class StatChangeIndicator extends InfoBox
{
private final boolean up;
private final BoostsPlugin plugin;

View File

@@ -28,7 +28,7 @@ import java.awt.Color;
import java.awt.image.BufferedImage;
import net.runelite.client.ui.overlay.infobox.InfoBox;
public class CannonCounter extends InfoBox
class CannonCounter extends InfoBox
{
private final CannonPlugin plugin;

View File

@@ -229,14 +229,12 @@ public class CannonPlugin extends Plugin
GameObject gameObject = event.getGameObject();
Player localPlayer = client.getLocalPlayer();
if (gameObject.getId() == CANNON_BASE && !cannonPlaced)
if (gameObject.getId() == CANNON_BASE && !cannonPlaced &&
localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 &&
localPlayer.getAnimation() == AnimationID.BURYING_BONES)
{
if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2
&& localPlayer.getAnimation() == AnimationID.BURYING_BONES)
{
cannonPosition = gameObject.getWorldLocation();
cannon = gameObject;
}
cannonPosition = gameObject.getWorldLocation();
cannon = gameObject;
}
}
@@ -250,17 +248,15 @@ public class CannonPlugin extends Plugin
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.
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,
// 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,
// we don't want to update the cannonball counter if it was set to a specific
// amount.
if (!skipProjectileCheckThisTick)
{
cballsLeft--;
}
!skipProjectileCheckThisTick)
{
cballsLeft--;
}
}
}
@@ -366,13 +362,10 @@ public class CannonPlugin extends Plugin
{
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!");
lock = true;
}
notifier.notify("Your cannon has " + this.ammoAmount + " balls left!");
lock = true;
}
return Color.red;

View File

@@ -818,7 +818,7 @@ public class ChatCommandsPlugin extends Plugin
}
catch (IOException e)
{
e.printStackTrace();
log.error("Error looking up prices", e);
}
int itemId = item.getId();
@@ -1166,7 +1166,7 @@ public class ChatCommandsPlugin extends Plugin
ItemPrice shortest = null;
for (ItemPrice item : items)
{
if (item.getName().toLowerCase().equals(originalInput.toLowerCase()))
if (item.getName().equalsIgnoreCase(originalInput.toLowerCase()))
{
return item;
}

View File

@@ -34,7 +34,7 @@ import net.runelite.client.callback.ClientThread;
import net.runelite.client.input.KeyListener;
@Singleton
public class ChatKeyboardListener implements KeyListener
class ChatKeyboardListener implements KeyListener
{
@Inject
private ChatCommandsConfig chatCommandsConfig;

View File

@@ -143,13 +143,11 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
case MODPRIVATECHAT:
final String name = Text.removeTags(chatMessage.getName());
// 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 (friends.size() >= FRIENDS_MAX_SIZE)
{
friends.remove();
}
friends.size() >= FRIENDS_MAX_SIZE)
{
friends.remove();
}
friends.add(name);
// intentional fall-through

View File

@@ -82,7 +82,7 @@ public class ChatNotificationsPlugin extends Plugin
private Pattern highlightMatcher = null;
// 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 String highlightWordsString;

View File

@@ -3,8 +3,20 @@ package net.runelite.client.plugins.chattranslation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays;
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 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.ConfigChanged;
import net.runelite.api.events.MenuEntryAdded;
@@ -24,11 +36,6 @@ import net.runelite.client.plugins.PluginType;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.ArrayUtils;
import javax.inject.Inject;
import javax.inject.Provider;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
@PluginDescriptor(
name = "Chat Translator",
description = "Translates messages from one Language to another.",
@@ -36,6 +43,7 @@ import java.util.ArrayList;
type = PluginType.UTILITY
)
@Singleton
@Slf4j
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 ArrayList<String> playerNames = new ArrayList<>();
private final Set<String> playerNames = new HashSet<>();
@Inject
private Client client;
@@ -84,12 +92,9 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
{
updateConfig();
if (client != null)
if (client != null && this.translateOptionVisable)
{
if (this.translateOptionVisable)
{
menuManager.get().addPlayerMenuItem(TRANSLATE);
}
menuManager.get().addPlayerMenuItem(TRANSLATE);
}
keyManager.registerKeyListener(this);
@@ -99,12 +104,9 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Override
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);
@@ -143,8 +145,6 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
if (groupId == WidgetInfo.CHATBOX.getGroupId())
{
boolean after;
if (!AFTER_OPTIONS.contains(option))
{
return;
@@ -223,7 +223,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
}
catch (Exception e)
{
e.printStackTrace();
log.warn(e.toString());
}
client.refreshChat();
@@ -246,47 +246,42 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
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();
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
if (message.startsWith("/"))
{
Translator translator = new Translator();
String message = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
if (message.startsWith("/"))
{
try
{
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translator.translate("auto", config.playerTargetLanguage().toString(), message));
}
catch (Exception e)
{
e.printStackTrace();
}
return;
}
event.consume();
try
{
//Automatically check language of message and translate to selected language.
String translation = translator.translate("auto", this.playerTargetLanguage.toString(), message);
if (translation != null)
{
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
clientThread.invoke(() ->
{
client.runScript(96, 0, translation);
});
}
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translator.translate("auto", config.playerTargetLanguage().toString(), message));
}
catch (Exception e)
{
e.printStackTrace();
log.warn("Translation error", e);
}
return;
}
event.consume();
try
{
//Automatically check language of message and translate to selected language.
String translation = translator.translate("auto", this.playerTargetLanguage.toString(), message);
if (translation != null)
{
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation);
clientThread.invoke(() ->
client.runScript(CHATBOX_TEXT, 0, translation));
}
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
}
catch (Exception e)
{
log.warn(e.toString());
}
}
}

View File

@@ -9,7 +9,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class Translator
class Translator
{
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()));
String inputLine;
StringBuffer response = new StringBuffer();
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null)
{

View File

@@ -121,13 +121,13 @@ public class ClanChatPlugin extends Plugin
return (CopyOnWriteArrayList<Player>) clanMembers.clone();
}
private static CopyOnWriteArrayList<Player> clanMembers = new CopyOnWriteArrayList<>();
private static final CopyOnWriteArrayList<Player> clanMembers = new CopyOnWriteArrayList<>();
private ClanChatIndicator clanMemberCounter;
/**
* queue of temporary messages added to the client
*/
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 boolean clanChatIcons;
@@ -151,7 +151,7 @@ public class ClanChatPlugin extends Plugin
public void startUp()
{
updateConfig();
chats = new ArrayList<>(Text.fromCSV(config.chatsData()));
chats = new ArrayList<>(Text.fromCSV(this.chatsData));
}
@Override
@@ -485,7 +485,7 @@ public class ClanChatPlugin extends Plugin
final Player local = client.getLocalPlayer();
final Player player = event.getPlayer();
if (player != local && player.isClanMember())
if (player != null && !player.equals(local) && player.isClanMember())
{
clanMembers.add(player);
addClanCounter();

View File

@@ -16,12 +16,12 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ClanManModeMinimapOverlay extends Overlay
{
private final ClanManModeService ClanManModeService;
private final ClanManModeConfig config;
private final ClanManModePlugin plugin;
@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;
setLayer(OverlayLayer.ABOVE_WIDGETS);
setPosition(OverlayPosition.DYNAMIC);
@@ -39,7 +39,7 @@ public class ClanManModeMinimapOverlay extends Overlay
{
final String name = actor.getName().replace('\u00A0', ' ');
if (config.drawMinimapNames())
if (plugin.isDrawMinimapNames())
{
final net.runelite.api.Point minimapLocation = actor.getMinimapLocation();

View File

@@ -17,12 +17,12 @@ import net.runelite.client.ui.overlay.OverlayUtil;
public class ClanManModeOverlay extends Overlay
{
private final ClanManModeService ClanManModeService;
private final ClanManModeConfig config;
private final ClanManModePlugin plugin;
@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;
setPosition(OverlayPosition.DYNAMIC);
setPriority(OverlayPriority.MED);
@@ -37,7 +37,7 @@ public class ClanManModeOverlay extends Overlay
private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color)
{
if (!config.drawOverheadPlayerNames())
if (!plugin.isDrawOverheadPlayerNames())
{
return;
}
@@ -48,7 +48,7 @@ public class ClanManModeOverlay extends Overlay
if (textLocation != null)
{
if (config.getClanAttackableColor().equals(color) && config.ShowBold())
if (plugin.getGetClanAttackableColor().equals(color) && plugin.isShowBold())
{
graphics.setFont(FontManager.getRunescapeBoldFont());
}

View File

@@ -1,11 +1,14 @@
package net.runelite.client.plugins.clanmanmode;
import com.google.inject.Provides;
import java.awt.Color;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Player;
@@ -49,6 +52,37 @@ public class ClanManModePlugin extends Plugin
@Inject
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
ClanManModeConfig provideConfig(ConfigManager configManager)
{
@@ -60,11 +94,13 @@ public class ClanManModePlugin extends Plugin
int clanmax;
int inwildy;
int ticks;
Map<String, Integer> clan = new HashMap<>();
final Map<String, Integer> clan = new HashMap<>();
@Override
protected void startUp() throws Exception
{
updateConfig();
overlayManager.add(ClanManModeOverlay);
overlayManager.add(ClanManModeTileOverlay);
overlayManager.add(ClanManModeMinimapOverlay);
@@ -91,6 +127,8 @@ public class ClanManModePlugin extends Plugin
{
return;
}
updateConfig();
}
@Subscribe
@@ -122,4 +160,23 @@ public class ClanManModePlugin extends Plugin
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();
}
}

View File

@@ -16,18 +16,16 @@ import net.runelite.api.coords.WorldPoint;
public class ClanManModeService
{
private final Client client;
private final ClanManModeConfig config;
private final ClanManModePlugin plugin;
@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.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)
{
@@ -39,12 +37,7 @@ public class ClanManModeService
int selfmax = localPlayer.getCombatLevel() + plugin.wildernessLevel;
for (Player player : client.getPlayers())
{
if (player == null || player.getName() == null)
{
continue;
}
if (player == localPlayer)
if (player == null || player.getName() == null || player.equals(localPlayer))
{
continue;
}
@@ -57,15 +50,9 @@ public class ClanManModeService
interactor = ((Player) interacting);
}
if (config.showAttackers())
if (plugin.isShowAttackers() && interactor != null && interactor.getName().equals(localName))
{
if (interactor != null)
{
if (interactor.getName().equals(localName))
{
consumer.accept(player, config.getAttackerColor());
}
}
consumer.accept(player, plugin.getGetAttackerColor());
}
if (plugin.inwildy == 1)
@@ -76,94 +63,82 @@ public class ClanManModeService
{
plugin.clan.put(player.getName(), player.getCombatLevel());
}
if (config.highlightAttacked())
if (plugin.isHighlightAttacked() && interactor != null && !interactors.containsKey(interactor.getName()))
{
if (interactor != null)
WorldPoint a = interactor.getWorldLocation();
int underLevel = ((a.getY() - 9920) / 8) + 1;
int upperLevel = ((a.getY() - 3520) / 8) + 1;
int wildernessLevel = a.getY() > 6400 ? underLevel : upperLevel;
int wildydiff = plugin.wildernessLevel - wildernessLevel;
if (wildydiff < 0)
{
if (!interactors.containsKey(interactor.getName()))
wildydiff = 0;
}
if (plugin.isCalcSelfCB())
{
if (interacting.getCombatLevel() <= selfmax && interacting.getCombatLevel() - wildydiff >= selfmin && !interactor.isClanMember())
{
WorldPoint a = interactor.getWorldLocation();
int underLevel = ((a.getY() - 9920) / 8) + 1;
int upperLevel = ((a.getY() - 3520) / 8) + 1;
int wildernessLevel = a.getY() > 6400 ? underLevel : upperLevel;
int wildydiff = plugin.wildernessLevel - wildernessLevel;
if (wildydiff < 0)
{
wildydiff = 0;
}
if (config.CalcSelfCB())
{
if (interacting.getCombatLevel() <= selfmax && interacting.getCombatLevel() - wildydiff >= selfmin && !interactor.isClanMember())
{
interactors.put(interactor.getName(), player.getName());
consumer.accept(interactor, config.getClanAttackableColor());
}
}
else
{
if (interacting.getCombatLevel() <= maxatk && interacting.getCombatLevel() - wildydiff >= minatk && !interactor.isClanMember())
{
interactors.put(interactor.getName(), player.getName());
consumer.accept(interactor, config.getClanAttackableColor());
}
}
interactors.put(interactor.getName(), player.getName());
consumer.accept(interactor, plugin.getGetClanAttackableColor());
}
}
else
{
if (interacting.getCombatLevel() <= maxatk && interacting.getCombatLevel() - wildydiff >= minatk && !interactor.isClanMember())
{
interactors.put(interactor.getName(), player.getName());
consumer.accept(interactor, plugin.getGetClanAttackableColor());
}
}
}
}
else
{
if (config.PersistentClan())
if (plugin.isPersistentClan() && plugin.clan.containsKey(player.getName()))
{
if (plugin.clan.containsKey(player.getName()))
{
consumer.accept(player, config.getClanMemberColor());
}
consumer.accept(player, plugin.getGetClanMemberColor());
}
if (config.highlightAttacked())
{
if (interactors.containsKey(player.getName()))
if (plugin.isHighlightAttacked() && interactors.containsKey(player.getName()))
{
String attackername = interactors.get(player.getName());
boolean found = false;
for (Player attacker : client.getPlayers())
String attackername = interactors.get(player.getName());
boolean found = false;
for (Player attacker : client.getPlayers())
{
if (attacker == null || attacker.getName() == null)
{
if (attacker == null || attacker.getName() == null)
continue;
}
if (attacker.getName().equals(attackername))
{
found = true;
Actor ainteract = attacker.getInteracting();
if (ainteract != null)
{
continue;
}
if (attacker.getName().equals(attackername))
{
found = true;
Actor ainteract = attacker.getInteracting();
if (ainteract != null)
if (ainteract.getName().equals(player.getName()))
{
if (ainteract.getName().equals(player.getName()))
{
consumer.accept(player, config.getClanAttackableColor());
}
else
{
interactors.remove(player.getName());
}
consumer.accept(player, plugin.getGetClanAttackableColor());
}
else
{
interactors.remove(player.getName());
}
break;
}
else
{
interactors.remove(player.getName());
}
break;
}
if (!found)
{
interactors.remove(player.getName());
}
continue;
}
if (!found)
{
interactors.remove(player.getName());
}
continue;
}
if (config.highlightAttackable())
if (plugin.isHighlightAttackable())
{
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;
}
@@ -176,18 +151,18 @@ public class ClanManModeService
{
wildydiff = 0;
}
if (config.CalcSelfCB())
if (plugin.isCalcSelfCB())
{
if (player.getCombatLevel() <= selfmax && player.getCombatLevel() - wildydiff >= selfmin)
{
consumer.accept(player, config.getAttackableColor());
consumer.accept(player, plugin.getGetAttackableColor());
}
}
else
{
if (player.getCombatLevel() <= maxatk && player.getCombatLevel() - wildydiff >= minatk)
{
consumer.accept(player, config.getAttackableColor());
consumer.accept(player, plugin.getGetAttackableColor());
}
}
}

View File

@@ -78,13 +78,10 @@ public class ClueScrollOverlay extends Overlay
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("Requires Spade!").leftColor(Color.RED).build());
}
panelComponent.getChildren().add(LineComponent.builder().left("").build());
panelComponent.getChildren().add(LineComponent.builder().left("Requires Spade!").leftColor(Color.RED).build());
}
return panelComponent.render(graphics);

View File

@@ -36,10 +36,8 @@ import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import javax.inject.Inject;
import javax.inject.Singleton;
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.worldmap.WorldMapPointManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.ItemUtil;
import net.runelite.client.util.Text;
@PluginDescriptor(
@@ -211,12 +210,9 @@ public class ClueScrollPlugin extends Plugin
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.")
@@ -231,9 +227,9 @@ public class ClueScrollPlugin extends Plugin
@Subscribe
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"))
{
@@ -262,30 +258,25 @@ public class ClueScrollPlugin extends Plugin
// Check if item was removed from inventory
if (clue != null && clueItemId != null)
{
final Stream<Item> items = Arrays.stream(event.getItemContainer().getItems());
// 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);
}
}
// 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;
npcsToMark.clear();
if (this.displayHintArrows)
{
worldMapPointsSet = false;
npcsToMark.clear();
if (this.displayHintArrows)
{
client.clearHintArrow();
}
checkClueNPCs(clue, client.getCachedNPCs());
client.clearHintArrow();
}
checkClueNPCs(clue, client.getCachedNPCs());
}
}
@@ -483,12 +474,9 @@ public class ClueScrollPlugin extends Plugin
final String text = Text.sanitizeMultilineText(clueScrollText.getText()).toLowerCase();
// 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:
@@ -773,7 +761,7 @@ public class ClueScrollPlugin extends Plugin
textComponent.render(graphics);
}
void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget ... toHighlight)
void scrollToWidget(WidgetInfo list, WidgetInfo scrollbar, Widget... toHighlight)
{
final Widget parent = client.getWidget(list);
int averageCentralY = 0;

View File

@@ -171,11 +171,11 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
if (digLocations.size() > 10)
{
for (HotColdArea area : locationCounts.keySet())
for (Map.Entry<HotColdArea, Integer> locationCount : locationCounts.entrySet())
{
panelComponent.getChildren().add(LineComponent.builder()
.left(area.getName())
.right(Integer.toString(locationCounts.get(area)))
.left(locationCount.getKey().getName())
.right(Integer.toString(locationCount.getValue()))
.build());
}
}

View File

@@ -29,7 +29,7 @@ import net.runelite.api.Item;
public class AllRequirementsCollection implements ItemRequirement
{
private ItemRequirement[] requirements;
private final ItemRequirement[] requirements;
public AllRequirementsCollection(ItemRequirement... requirements)
{

View File

@@ -29,8 +29,8 @@ import net.runelite.api.Item;
public class AnyRequirementCollection implements ItemRequirement
{
private String name;
private ItemRequirement[] requirements;
private final String name;
private final ItemRequirement[] requirements;
public AnyRequirementCollection(String name, ItemRequirement... requirements)
{

View File

@@ -29,9 +29,9 @@ import net.runelite.api.Item;
public class RangeItemRequirement implements ItemRequirement
{
private String name;
private int startItemId;
private int endItemId;
private final String name;
private final int startItemId;
private final int endItemId;
public RangeItemRequirement(String name, int startItemId, int endItemId)
{

View File

@@ -30,7 +30,7 @@ import net.runelite.api.ItemDefinition;
public class SingleItemRequirement implements ItemRequirement
{
private int itemId;
private final int itemId;
public SingleItemRequirement(int itemId)
{

View File

@@ -30,8 +30,8 @@ import net.runelite.api.Item;
public class SlotLimitationRequirement implements ItemRequirement
{
private String description;
private EquipmentInventorySlot[] slots;
private final String description;
private final EquipmentInventorySlot[] slots;
public SlotLimitationRequirement(String description, EquipmentInventorySlot... slots)
{

View File

@@ -24,13 +24,26 @@
*/
package net.runelite.client.plugins.combatcounter;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
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 lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
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.Hitsplat;
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.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(
name = "Tick Counter",
description = "Count the amount of perfect combat ticks performed by each player.",
@@ -64,6 +70,7 @@ import java.util.Map;
enabledByDefault = false
)
@Singleton
@Slf4j
public class CombatCounter extends Plugin
{
@@ -87,9 +94,9 @@ public class CombatCounter extends Plugin
@Getter(AccessLevel.PACKAGE)
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<>();
@Getter(AccessLevel.PACKAGE)
@@ -114,130 +121,116 @@ public class CombatCounter extends Plugin
return configManager.getConfig(CombatCounterConfig.class);
}
private Map<Integer, Integer> variables = new HashMap<Integer, Integer>()
{
{
this.put(422, 4); // Unarmed Punch, Block
this.put(423, 4); // Unarmed Kick
private static final Map<Integer, Integer> VARIABLES = ImmutableMap.<Integer, Integer>builder()
.put(422, 4) // Unarmed Punch, Block
.put(423, 4) // Unarmed Kick
this.put(8145, 4); // Rapier Stab, Lunge, Block
this.put(390, 4); // Rapier Slash
.put(8145, 4) // Rapier Stab, Lunge, Block
.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
this.put(1378, 6); // Dragon Warhammer Special
.put(401, 6) // Dragon Warhammer Pound, Pummel, Block
.put(1378, 6) // Dragon Warhammer Special
this.put(393, 4); // Dragon Claws Chop, Slash, Block
this.put(1067, 4); // Dragon Claws Lunge
this.put(7514, 4); // Dragon Claws Special
.put(393, 4) // Dragon Claws Chop, Slash, Block
.put(1067, 4) // Dragon Claws Lunge
.put(7514, 4) // Dragon Claws Special
this.put(8288, 4); // Dragon Hunter Lance Lunge, Block
this.put(8289, 4); // Dragon Hunter Lance Swipe
this.put(8290, 4); // Dragon Hunter Lance Pound
.put(8288, 4) // Dragon Hunter Lance Lunge, Block
.put(8289, 4) // Dragon Hunter Lance Swipe
.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
this.put(7054, 6); // Bandos Godsword Smash
this.put(7055, 6); // Bandos Godsword Block
this.put(7642, 6); // Bandos Godsword Special
this.put(7643, 6); // Bandos Godsword Special (Ornamate)
.put(7045, 6) // Bandos Godsword Chop, Slash
.put(7054, 6) // Bandos Godsword Smash
.put(7055, 6) // Bandos Godsword Block
.put(7642, 6) // Bandos Godsword Special
.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
this.put(440, 4); // Staff of Light Swipe
this.put(419, 4); // Staff of Light Fend
this.put(7967, 4); // Staff of Light Special
// .put(428, 4) // Staff of Light Jab
.put(440, 4) // Staff of Light Swipe
//.put(419, 4) // Staff of Light Fend
.put(7967, 4) // Staff of Light Special
this.put(428, 7); // Crystal Halberd Jab, Fend
this.put(419, 7); // Crystal Halberd Swipe
this.put(1203, 7); // Crystal Halberd Special
.put(428, 7) // Crystal Halberd Jab, Fend
.put(419, 7) // Crystal Halberd Swipe
.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
this.put(1978, 5); // Ancient Magicks Blitz
.put(1979, 5) // Ancient Magicks Barrage
.put(1978, 5) // Ancient Magicks Blitz
this.put(7618, 3); // Chinchompa Short, Medium, Long Fuse
this.put(1658, 4); // Whip Flick, Lash, Deflect
.put(7618, 3) // Chinchompa Short, Medium, Long Fuse
.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
this.add(390); // Rapier Slash
private static final Set<Integer> MELEE_ANIMATIONS = ImmutableSet.<Integer>builder()
.add(422) // Unarmed Punch, Block
.add(423) // Unarmed Kick
this.add(401); // Dragon Warhammer Pound, Pummel, Block
this.add(1378); // Dragon Warhammer Special
.add(8145) // Rapier Stab, Lunge, Block
.add(390) // Rapier Slash
this.add(393); // Dragon Claws Chop, Slash, Block
this.add(1067); // Dragon Claws Lunge
this.add(7514); // Dragon Claws Special
.add(401) // Dragon Warhammer Pound, Pummel, Block
.add(1378) // Dragon Warhammer Special
this.add(8288); // Dragon Hunter Lance Lunge, Block
this.add(8289); // Dragon Hunter Lance Swipe
this.add(8290); // Dragon Hunter Lance Pound
.add(393) // Dragon Claws Chop, Slash, Block
.add(1067) // Dragon Claws Lunge
.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
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)
.add(8056) // Scythe of Vitur Reap, Chop, Jab, Block
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
this.add(440); // Staff of Light Swipe
this.add(419); // Staff of Light Fend
.add(414) // Kodai Bash, Pound, Focus
this.add(428); // Crystal Halberd Jab, Fend
this.add(419); // Crystal Halberd Swipe
this.add(1203); // Crystal Halberd Special
.add(428) // Staff of Light Jab
.add(440) // Staff of Light Swipe
.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>()
{
{
this.add(7552); // Armadyl Crossbow Accurate, Rapid, Longrange, Special
.add(1658) // Whip Flick, Lash, Deflect
.build();
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
this.add(7555); // Ballista Accurate, Rapid, Longrange
}
};
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
}
};
private static final Set<Integer> MAGE_ANIMATIONS = ImmutableSet.of(
1167, // Trident Accurate, Accurate, Longrange
1978, // Ancient Magicks Blitz
1979 // Ancient Magicks Barrage
);
@Override
protected void startUp() throws Exception
@@ -279,23 +272,24 @@ public class CombatCounter extends Plugin
int animation = p.getAnimation();
if (animation != -1)
{
if (variables.containsKey(animation))
if (VARIABLES.containsKey(animation))
{
/*
* This part handles the Tick Counter.
*/
long ticks = variables.get(animation);
long ticks = VARIABLES.get(animation);
if (((Player) actor).getPlayerAppearance().getEquipmentId(KitType.WEAPON) == 23360)
{
ticks = 3;
}
if (counter.containsKey(name))
{
ticks += counter.get(name);
}
counter.put(name, ticks);
counter = sortByValue(counter);
long BLOWPIPE_ID = 5061;
if (animation == BLOWPIPE_ID)
if (animation == BLOWPIPE_ATTACK)
{
this.blowpipe.put(name, -4L);
}
@@ -311,7 +305,7 @@ public class CombatCounter extends Plugin
List<NPC> actives = new ArrayList<>();
actives.add(npc);
if (animation == 1979 || animation == 7618)
if (BARRAGE_ANIMATION == 1979 || CHIN_ANIMATION == 7618)
{ // Barrage or chin.
for (NPC nearby : this.client.getNpcs())
{
@@ -354,7 +348,7 @@ public class CombatCounter extends Plugin
}
else
{
System.out.println("Unclassified Animation: " + animation);
log.debug("Unclassified Animation: {}", animation);
}
if (delay != -1)
@@ -379,13 +373,17 @@ public class CombatCounter extends Plugin
{
NPCDamageCounter dc = new NPCDamageCounter();
if (this.npcDamageMap.containsKey(target))
{
dc = this.npcDamageMap.get(target);
}
for (Integer tick : ticksToAdd)
{
List<String> attackers = new ArrayList<>();
if (dc.attackers.containsKey(tick))
{
attackers = dc.attackers.get(tick);
}
attackers.add(name);
dc.attackers.put(tick, attackers);
@@ -425,7 +423,9 @@ public class CombatCounter extends Plugin
for (Player p : this.client.getPlayers())
{
if (p.getName() != null)
{
visible.put(p.getName(), p);
}
}
for (NPC npc : new ArrayList<>(this.npcDamageMap.keySet()))
@@ -442,7 +442,9 @@ public class CombatCounter extends Plugin
double totalDamage = 0d;
for (Integer damage : counter.damage)
{
totalDamage += damage;
}
if (attackers.containsKey(-1))
{
@@ -454,7 +456,9 @@ public class CombatCounter extends Plugin
{
double count = 0d;
if (this.playerDamage.containsKey(name))
{
count = this.playerDamage.get(name);
}
count += damagePerPlayer;
this.playerDamage.put(name, count);
@@ -475,11 +479,17 @@ public class CombatCounter extends Plugin
// }
for (Integer i : new ArrayList<>(attackers.keySet()))
{
if (i <= -1)
{
attackers.remove(i);
}
}
if (attackers.isEmpty())
{
this.npcDamageMap.remove(npc);
}
}
this.playerDamage = sortByValue(this.playerDamage);
@@ -508,20 +518,26 @@ public class CombatCounter extends Plugin
NPCDamageCounter dc = new NPCDamageCounter();
if (this.npcDamageMap.containsKey(npc))
{
dc = this.npcDamageMap.get(npc);
}
int delay = this.calculateBPDelay(distance);
List<Integer> counts = new ArrayList<>();
counts.add(delay);
if (delay > 2)
{
counts.add(delay - 1);
}
for (int tick : counts)
{
List<String> attackers = new ArrayList<>();
if (dc.attackers.containsKey(tick))
{
attackers = dc.attackers.get(tick);
}
attackers.add(user);
dc.attackers.put(tick, attackers);
@@ -545,12 +561,16 @@ public class CombatCounter extends Plugin
Actor actor = event.getActor();
if (!(actor instanceof NPC))
{
return;
}
NPC npc = (NPC) actor;
if (!this.npcDamageMap.containsKey(npc))
{
return;
}
Hitsplat splat = event.getHitsplat();
NPCDamageCounter dc = this.npcDamageMap.get(npc);
@@ -586,6 +606,7 @@ public class CombatCounter extends Plugin
int distance = wpNPC.distanceTo(wpPlayer);
if (size > 1)
{
for (int x = 0; x < size; x++)
{
for (int y = 0; y < size; y++)
@@ -598,6 +619,8 @@ public class CombatCounter extends Plugin
}
}
}
}
return distance;
}

View File

@@ -96,17 +96,18 @@ class CombatOverlay extends Overlay
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))
{
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
{
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()))

View File

@@ -97,16 +97,16 @@ class DamageOverlay extends Overlay
return null;
}
for (String name : map.keySet())
for (Map.Entry<String, Double> damage : map.entrySet())
{
String val = String.format("%.1f", map.get(name));
if (client.getLocalPlayer().getName().contains(name))
String val = String.format("%.1f", damage.getValue());
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
{
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()));
}
}

View File

@@ -10,9 +10,9 @@ import javax.inject.Singleton;
class NPCDamageCounter
{
Map<Integer, List<String>> attackers;
final Map<Integer, List<String>> attackers;
List<Integer> damage;
final List<Integer> damage;
NPCDamageCounter()
{

View File

@@ -119,7 +119,7 @@ public class CombatLevelPlugin extends Plugin
if (widgetText.contains("."))
{
combatLevelWidget.setText(widgetText.substring(0, widgetText.indexOf(".")));
combatLevelWidget.setText(widgetText.substring(0, widgetText.indexOf('.')));
}
}

View File

@@ -48,6 +48,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;
import javax.inject.Singleton;
@@ -992,7 +993,7 @@ public class ConfigPanel extends PluginPanel
if (e.getStateChange() == ItemEvent.SELECTED)
{
changeConfiguration(listItem, config, box, cd, cid);
box.setToolTipText(box.getSelectedItem().toString());
box.setToolTipText(Objects.requireNonNull(box.getSelectedItem()).toString());
}
});
item.add(box, BorderLayout.EAST);
@@ -1175,7 +1176,7 @@ public class ConfigPanel extends PluginPanel
else if (component instanceof JComboBox)
{
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())
{

View File

@@ -10,8 +10,8 @@ import javax.swing.event.DocumentListener;
class DeferredDocumentChangedListener implements DocumentListener
{
private Timer timer;
private List<ChangeListener> listeners;
private final Timer timer;
private final List<ChangeListener> listeners;
DeferredDocumentChangedListener()
{

View File

@@ -34,7 +34,7 @@ import net.runelite.client.config.Keybind;
import net.runelite.client.config.ModifierlessKeybind;
@Singleton
public class HotkeyButton extends JButton
class HotkeyButton extends JButton
{
@Getter(AccessLevel.PACKAGE)
private Keybind value;
@@ -43,9 +43,7 @@ public class HotkeyButton extends JButton
{
setValue(value);
addActionListener(e ->
{
setValue(Keybind.NOT_SET);
});
setValue(Keybind.NOT_SET));
addKeyListener(new KeyAdapter()
{
@Override
@@ -63,7 +61,7 @@ public class HotkeyButton extends JButton
});
}
public void setValue(Keybind value)
private void setValue(Keybind value)
{
if (value == null)
{

View File

@@ -62,7 +62,6 @@ public class PluginListItem extends JPanel
private static final ImageIcon OFF_STAR;
private final ConfigPanel configPanel;
public final ConfigManager configManager;
@Getter
@Nullable
@@ -144,7 +143,6 @@ public class PluginListItem extends JPanel
@Nullable ConfigDescriptor configDescriptor, String name, String description, String... tags)
{
this.configPanel = configPanel;
this.configManager = configManager;
this.plugin = plugin;
this.config = config;
this.configDescriptor = configDescriptor;
@@ -186,7 +184,7 @@ public class PluginListItem extends JPanel
buttonPanel.add(configButton);
// 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 ->
{

View File

@@ -224,7 +224,7 @@ public class CorpPlugin extends Plugin
Actor source = interactingChanged.getSource();
Actor target = interactingChanged.getTarget();
if (corp == null || target != corp)
if (target != corp)
{
return;
}

View File

@@ -112,12 +112,9 @@ public class DeathIndicatorPlugin extends Plugin
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())

View File

@@ -53,8 +53,8 @@ public class DemonicGorillaOverlay extends Overlay
private static final int OVERLAY_ICON_DISTANCE = 50;
private static final int OVERLAY_ICON_MARGIN = 8;
private Client client;
private DemonicGorillaPlugin plugin;
private final Client client;
private final DemonicGorillaPlugin plugin;
@Inject
private SkillIconManager iconManager;

View File

@@ -206,7 +206,8 @@ public class DemonicGorillaPlugin extends Plugin
}
boolean correctPrayer =
target == null || // If player is out of memory, assume prayer was correct
attackStyle == protectedStyle;
(attackStyle != null &&
attackStyle.equals(protectedStyle));
if (attackStyle == DemonicGorilla.AttackStyle.BOULDER)
{

View File

@@ -160,7 +160,7 @@ class DevToolsOverlay extends Overlay
for (Player p : players)
{
if (p != local)
if (!p.equals(local))
{
String text = p.getName() + " (A: " + p.getAnimation() + ") (G: " + p.getSpotAnimation() + ")";
OverlayUtil.renderActorOverlay(graphics, p, text, BLUE);

View File

@@ -86,7 +86,6 @@ class VarInspector extends JFrame
private final static int MAX_LOG_ENTRIES = 10_000;
private final Client client;
private final DevToolsPlugin plugin;
private final EventBus eventBus;
private final JPanel tracker = new JPanel();
@@ -104,7 +103,6 @@ class VarInspector extends JFrame
{
this.eventBus = eventBus;
this.client = client;
this.plugin = plugin;
setTitle("RuneLite Var Inspector");
setIconImage(ClientUI.ICON);

View File

@@ -63,7 +63,6 @@ class WidgetInspector extends JFrame
private final ClientThread clientThread;
private final DevToolsConfig config;
private final DevToolsOverlay overlay;
private final DevToolsPlugin plugin;
private final JTree widgetTree;
private final WidgetInfoTableModel infoTableModel;
@@ -86,7 +85,6 @@ class WidgetInspector extends JFrame
this.infoTableModel = infoTableModel;
this.config = config;
this.overlay = overlay;
this.plugin = plugin;
eventBus.register(this);

View File

@@ -301,7 +301,6 @@ enum DiscordGameEventType
this.details = training(skill);
this.priority = priority;
this.imageKey = imageKeyOf(skill);
this.priority = priority;
this.shouldTimeout = true;
}

View File

@@ -86,8 +86,6 @@ import okhttp3.Response;
@Singleton
public class DiscordPlugin extends Plugin
{
private static boolean discordEnabled = false;
@Inject
private Client client;
@@ -112,7 +110,7 @@ public class DiscordPlugin extends Plugin
@Inject
private WSClient wsClient;
private Map<Skill, Integer> skillExp = new HashMap<>();
private final Map<Skill, Integer> skillExp = new HashMap<>();
private NavigationButton discordButton;
private boolean loginFlag;
@@ -159,7 +157,6 @@ public class DiscordPlugin extends Plugin
}
wsClient.registerMessage(DiscordUserInfo.class);
discordEnabled = true;
}
@Override
@@ -169,7 +166,6 @@ public class DiscordPlugin extends Plugin
discordState.reset();
partyService.changeParty(null);
wsClient.unregisterMessage(DiscordUserInfo.class);
discordEnabled = false;
}
@Subscribe
@@ -342,17 +338,14 @@ public class DiscordPlugin extends Plugin
{
final PartyMember localMember = partyService.getLocalMember();
if (localMember != null)
if (localMember != null && discordService.getCurrentUser() != null)
{
if (discordService.getCurrentUser() != null)
{
final DiscordUserInfo userInfo = new DiscordUserInfo(
discordService.getCurrentUser().userId,
discordService.getCurrentUser().avatar);
final DiscordUserInfo userInfo = new DiscordUserInfo(
discordService.getCurrentUser().userId,
discordService.getCurrentUser().avatar);
userInfo.setMemberId(localMember.getMemberId());
wsClient.send(userInfo);
}
userInfo.setMemberId(localMember.getMemberId());
wsClient.send(userInfo);
}
}
@@ -452,7 +445,7 @@ public class DiscordPlugin extends Plugin
return false;
}
public void updateConfig()
private void updateConfig()
{
this.actionTimeout = config.actionTimeout();
this.hideElapsedTime = config.hideElapsedTime();

View File

@@ -46,7 +46,7 @@ import static net.runelite.client.ws.PartyService.PARTY_MAX;
class DiscordState
{
@Data
private class EventWithTime
private static class EventWithTime
{
private final DiscordGameEventType type;
private final Instant start;
@@ -57,7 +57,7 @@ class DiscordState
private final List<EventWithTime> events = new ArrayList<>();
private final DiscordService discordService;
private final DiscordPlugin plugin;
private PartyService party;
private final PartyService party;
private final RuneLiteProperties properties;
private DiscordPresence lastPresence;

View File

@@ -49,14 +49,14 @@ import net.runelite.client.ui.PluginPanel;
@Slf4j
@Singleton
public class EquipmentInspectorPanel extends PluginPanel
class EquipmentInspectorPanel extends PluginPanel
{
private final static String NO_PLAYER_SELECTED = "No player selected";
private GridBagConstraints c;
private JPanel equipmentPanels;
private JPanel header;
private JLabel nameLabel;
private final GridBagConstraints c;
private final JPanel equipmentPanels;
private final JPanel header;
private final JLabel nameLabel;
@Inject
private ItemManager itemManager;

View File

@@ -306,7 +306,7 @@ public class EquipmentInspectorPlugin extends Plugin
}
}
public void updateConfig()
private void updateConfig()
{
this.ShowValue = config.ShowValue();
this.protecteditems = config.protecteditems();

View File

@@ -354,7 +354,7 @@ public class ExaminePlugin extends Plugin
}
catch (IOException e)
{
e.printStackTrace();
log.error(e.toString());
}
message
.append(ChatColorType.NORMAL)

View File

@@ -103,7 +103,7 @@ public class XpDropPlugin extends Plugin
private boolean hasDropped = false;
private boolean correctPrayer;
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 XpDropConfig.DamageMode damageMode;
@@ -401,12 +401,10 @@ public class XpDropPlugin extends Plugin
final String[] stringStack = client.getStringStack();
final int stringStackSize = client.getStringStackSize();
StringBuilder builder = new StringBuilder()
.append(stringStack[stringStackSize - 1])
.append(ColorUtil.colorTag(this.damageColor))
.append(" (").append(damage).append(")");
stringStack[stringStackSize - 1] = builder.toString();
String builder = stringStack[stringStackSize - 1] +
ColorUtil.colorTag(this.damageColor) +
" (" + damage + ")";
stringStack[stringStackSize - 1] = builder;
}
}

View File

@@ -252,11 +252,10 @@ public class FairyRingPlugin extends Plugin
return;
}
if (codes != null)
{
if (codes != null &&
// 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
if (codes.stream().noneMatch(w ->
codes.stream().noneMatch(w ->
{
Widget codeWidget = w.getCode();
if (codeWidget == null)
@@ -265,9 +264,8 @@ public class FairyRingPlugin extends Plugin
}
return list.getChild(codeWidget.getIndex()) == codeWidget;
}))
{
codes = null;
}
{
codes = null;
}
if (codes == null)

View File

@@ -69,8 +69,8 @@ public class FeedPlugin extends Plugin
private FeedPanel feedPanel;
private NavigationButton navButton;
private FeedClient feedClient = new FeedClient();
private Supplier<FeedResult> feedSupplier = Suppliers.memoizeWithExpiration(() ->
private final FeedClient feedClient = new FeedClient();
private final Supplier<FeedResult> feedSupplier = Suppliers.memoizeWithExpiration(() ->
{
try
{

View File

@@ -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),
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
{

View File

@@ -48,9 +48,9 @@ import net.runelite.client.util.ImageUtil;
@Singleton
public class FightCaveOverlay extends Overlay
{
private FightCavePlugin plugin;
private Client client;
private SpriteManager spriteManager;
private final FightCavePlugin plugin;
private final Client client;
private final SpriteManager spriteManager;
@Inject
FightCaveOverlay(final Client client, final FightCavePlugin plugin, final SpriteManager spriteManager)

View File

@@ -171,14 +171,11 @@ public class FightCavePlugin extends Plugin
{
updateConfig();
if (client.getGameState() == GameState.LOGGED_IN)
if (client.getGameState() == GameState.LOGGED_IN && regionCheck())
{
if (regionCheck())
{
validRegion = true;
overlayManager.add(waveOverlay);
overlayManager.add(fightCaveOverlay);
}
validRegion = true;
overlayManager.add(waveOverlay);
overlayManager.add(fightCaveOverlay);
}
}

View File

@@ -33,7 +33,7 @@ import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.client.ui.overlay.Overlay;
@@ -65,7 +65,7 @@ public class FlexoOverlay extends Overlay
if (plugin.isDebugNPCs() || plugin.isDebugGroundItems() || plugin.isDebugPlayers())
{
ArrayList<Rectangle> clickAreas = plugin.getClickAreas();
List<Rectangle> clickAreas = plugin.getClickAreas();
if (clickAreas != null)
{
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)
{
for (Point p : clickPoints)

View File

@@ -134,9 +134,9 @@ public class FlexoPlugin extends Plugin
private int scalingFactor;
@Getter(AccessLevel.PACKAGE)
private ArrayList<Rectangle> clickAreas = new ArrayList<>();
private List<Rectangle> clickAreas = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private ArrayList<Point> clickPoints = new ArrayList<>();
private List<Point> clickPoints = new ArrayList<>();
@Subscribe
private void onConfigChanged(ConfigChanged event)
@@ -172,15 +172,12 @@ public class FlexoPlugin extends Plugin
{
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());
this.clickAreas.add(r);
java.awt.Point p = FlexoMouse.getClickPoint(r);
this.clickPoints.add(p);
}
Rectangle r = FlexoMouse.getClickArea(npc.getConvexHull().getBounds());
this.clickAreas.add(r);
java.awt.Point p = FlexoMouse.getClickPoint(r);
this.clickPoints.add(p);
}
}
}
@@ -194,15 +191,12 @@ public class FlexoPlugin extends Plugin
{
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());
this.clickAreas.add(r);
java.awt.Point p = FlexoMouse.getClickPoint(r);
this.clickPoints.add(p);
}
Rectangle r = FlexoMouse.getClickArea(player.getConvexHull().getBounds());
this.clickAreas.add(r);
java.awt.Point p = FlexoMouse.getClickPoint(r);
this.clickPoints.add(p);
}
}
}
@@ -214,27 +208,21 @@ public class FlexoPlugin extends Plugin
Flexo.isStretched = client.isStretchedEnabled();
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());
if (lp != null && Perspective.getCanvasTilePoly(client, lp) != null)
{
LocalPoint lp = LocalPoint.fromWorld(client, gi.getLocation());
if (lp != null)
{
if (Perspective.getCanvasTilePoly(client, lp) != null)
{
Rectangle r1 = FlexoMouse.getClickArea(Perspective.getCanvasTilePoly(client, lp).getBounds());
Rectangle r2 = FlexoMouse.getClickArea(r1);
Rectangle r3 = FlexoMouse.getClickArea(r2);
this.clickAreas.add(r3);
java.awt.Point p = FlexoMouse.getClickPoint(r3);
this.clickPoints.add(p);
}
}
Rectangle r1 = FlexoMouse.getClickArea(Perspective.getCanvasTilePoly(client, lp).getBounds());
Rectangle r2 = FlexoMouse.getClickArea(r1);
Rectangle r3 = FlexoMouse.getClickArea(r2);
this.clickAreas.add(r3);
java.awt.Point p = FlexoMouse.getClickPoint(r3);
this.clickPoints.add(p);
}
}
}

View File

@@ -54,7 +54,7 @@ public class FpsDrawListener implements Runnable
// Working set
private long lastMillis = 0;
private long[] lastDelays = new long[SAMPLE_SIZE];
private final long[] lastDelays = new long[SAMPLE_SIZE];
private int lastDelayIndex = 0;
private long sleepDelay = 0;

View File

@@ -55,7 +55,7 @@ public class FreezeTimersOverlay extends Overlay
private final BufferedImage FREEZE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "freeze.png");
private final BufferedImage TB_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "teleblock.png");
private final BufferedImage VENG_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "veng.png");
private Timers timers;
private final Timers timers;
@Inject
@@ -257,7 +257,7 @@ public class FreezeTimersOverlay extends Overlay
xOffset);
}
public void renderImageLocation(Graphics2D graphics, Point imgLoc, BufferedImage image)
private void renderImageLocation(Graphics2D graphics, Point imgLoc, BufferedImage image)
{
int x = imgLoc.getX();
int y = imgLoc.getY();

View File

@@ -162,7 +162,7 @@ public class FreezeTimersPlugin extends Plugin
this.remove(player);
}
public void remove(Actor actor)
private void remove(Actor actor)
{
freezes.remove(actor.getName());
}

View File

@@ -24,6 +24,7 @@
package net.runelite.client.plugins.freezetimers;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@@ -34,14 +35,14 @@ import net.runelite.api.Player;
@Slf4j
@Singleton
public class PrayerTracker
class PrayerTracker
{
@Inject
private Client client;
private HashMap<Actor, HashMap<String, Integer>> lastTick = new HashMap<>();
private HashMap<Actor, HashMap<String, Integer>> newTick = new HashMap<>();
private final Map<Actor, HashMap<String, Integer>> lastTick = new HashMap<>();
private final Map<Actor, HashMap<String, Integer>> newTick = new HashMap<>();
public void gameTick()
{

View File

@@ -24,15 +24,16 @@
package net.runelite.client.plugins.freezetimers;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Actor;
@Slf4j
@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()
{

View File

@@ -63,13 +63,13 @@ public class FriendTaggingPlugin extends Plugin
private static final String KEY_PREFIX = "tag_";
private static final String ADD_TAG = "Add 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);
private WidgetMenuOption ignoreTabMenuOption = new WidgetMenuOption("Copy to", "clipboard",
private final WidgetMenuOption ignoreTabMenuOption = new WidgetMenuOption("Copy to", "clipboard",
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);
private WidgetMenuOption ignoreTabResizableOption = new WidgetMenuOption("Copy to", "clipboard",
private final WidgetMenuOption ignoreTabResizableOption = new WidgetMenuOption("Copy to", "clipboard",
WidgetInfo.FIXED_VIEWPORT_IGNORES_TAB);
@Inject

View File

@@ -841,7 +841,8 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
// Re-create fbo
if (lastStretchedCanvasWidth != stretchedCanvasWidth
|| lastStretchedCanvasHeight != stretchedCanvasHeight
|| lastAntiAliasingMode != antiAliasingMode)
|| (lastAntiAliasingMode != null
&& !lastAntiAliasingMode.equals(antiAliasingMode)))
{
shutdownSceneFbo();
@@ -1012,7 +1013,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
final AnisotropicFilteringMode anisotropicFilteringMode = this.anisotropicFilteringMode;
final boolean afEnabled = anisotropicFilteringMode != AnisotropicFilteringMode.DISABLED;
if (lastAnisotropicFilteringMode != anisotropicFilteringMode)
if (lastAnisotropicFilteringMode != null && !lastAnisotropicFilteringMode.equals(anisotropicFilteringMode))
{
if (afEnabled)
{

View File

@@ -126,21 +126,15 @@ class SceneUploader
}
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();
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();

View File

@@ -28,6 +28,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
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.
for (GraphicsObject graphicsObject : client.getGraphicsObjects())
{
Color color = null;
Color color;
if (graphicsObject.getId() >= GROTESQUE_GUARDIANS_LIGHTNING_START && graphicsObject.getId() <= GROTESQUE_GUARDIANS_LIGHTNING_END)
{
@@ -99,22 +100,19 @@ class GrotesqueGuardiansOverlay extends Overlay
{
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();
LocalPoint duskPoint;
TextComponent textComponent = new TextComponent();
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);
net.runelite.api.Point duskLoc = Perspective.getCanvasTextLocation(client, graphics, duskPoint, "RUN AWAY", 500);
if (duskLoc != null)
{
textComponent.setText("RUN AWAY");
textComponent.setPosition(new java.awt.Point(duskLoc.getX(), duskLoc.getY()));
textComponent.setColor(Color.red);
textComponent.render(graphics);
}
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);
if (duskLoc != null)
{
textComponent.setText("RUN AWAY");
textComponent.setPosition(new java.awt.Point(duskLoc.getX(), duskLoc.getY()));
textComponent.setColor(Color.red);
textComponent.render(graphics);
}
}
}

View File

@@ -29,6 +29,7 @@ import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Objects;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
@@ -70,7 +71,7 @@ public class GrotesqueGuardiansPrayerOverlay extends Overlay
if ((plugin.isInGargs()) && (plugin.getPrayAgainst() != null) && (plugin.getDusk() != null))
{
DuskAttack attack = plugin.getPrayAgainst();
BufferedImage prayerImage = null;
BufferedImage prayerImage;
prayerImage = getPrayerImage(attack);
imagePanelComponent.setBackgroundColor(client
.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));
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);
if (duskLoc != null)
{

View File

@@ -36,7 +36,7 @@ import net.runelite.client.input.KeyListener;
import net.runelite.client.input.MouseAdapter;
@Singleton
public class GroundItemInputListener extends MouseAdapter implements KeyListener
class GroundItemInputListener extends MouseAdapter implements KeyListener
{
private static final int HOTKEY = KeyEvent.VK_ALT;
@@ -119,14 +119,11 @@ public class GroundItemInputListener extends MouseAdapter implements KeyListener
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);
e.consume();
return e;
}
plugin.updateList(plugin.getTextBoxBounds().getValue().getName(), true);
e.consume();
return e;
}
}

View File

@@ -352,7 +352,11 @@ public class GroundItemsOverlay extends Overlay
plugin.setHighlightBoxBounds(new SimpleEntry<>(itemHighlightBox, item));
}
boolean topItem = topGroundItem == item;
boolean topItem = false;
if (topGroundItem != null)
{
topItem = topGroundItem.equals(item);
}
// Draw background if hovering
if (topItem && (mouseInBox || mouseInHiddenBox || mouseInHighlightBox))

View File

@@ -273,7 +273,10 @@ public class GroundItemsPlugin extends Plugin
{
for (GroundItem item : collectedGroundItems.values())
{
if (item.getTicks() == -1) continue;
if (item.getTicks() == -1)
{
continue;
}
item.setTicks(item.getTicks() - 1);
}
}
@@ -488,21 +491,31 @@ public class GroundItemsPlugin extends Plugin
if (this.rightClickHidden)
{
if (aHidden && bMenuType == WALK)
{
return -1;
}
if (bHidden && aMenuType == WALK)
{
return 1;
}
}
// sort hidden items below non-hidden items
if (aHidden && !bHidden && bMenuType != WALK)
{
return -1;
}
if (bHidden && !aHidden && aMenuType != WALK)
{
return 1;
}
// RS sorts by alch price by private, so no need to sort if config not set
if (this.sortByGEPrice)
{
return (getGePriceFromItemId(aId) * aQuantity) - (getGePriceFromItemId(bId) * bQuantity);
}
}
}
@@ -738,11 +751,11 @@ public class GroundItemsPlugin extends Plugin
if (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
if (!itemNameIncludesQuantity || matches >= 1)
{
lastMatch = matcher.group(1);
}
matches++;
}

View File

@@ -129,15 +129,11 @@ public class HiscorePanel extends PluginPanel
private final List<JLabel> skillLabels = new ArrayList<>();
private final JPanel statsPanel = new JPanel();
/* Container of all the selectable endpoints (ironman, deadman, etc) */
private final MaterialTabGroup tabGroup;
private final HiscoreClient hiscoreClient = new HiscoreClient();
private HiscoreResult result;
/* The currently selected endpoint */
private HiscoreEndpoint selectedEndPoint;
@@ -247,6 +243,7 @@ public class HiscorePanel extends PluginPanel
// Panel that holds skill icons
GridLayout stats = new GridLayout(8, 3);
JPanel statsPanel = new JPanel();
statsPanel.setLayout(stats);
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
statsPanel.setBorder(new EmptyBorder(5, 0, 5, 0));
@@ -371,6 +368,7 @@ public class HiscorePanel extends PluginPanel
selectedEndPoint = HiscoreEndpoint.NORMAL;
}
HiscoreResult result;
try
{
log.debug("Hiscore endpoint " + selectedEndPoint.name() + " selected");
@@ -607,7 +605,11 @@ public class HiscorePanel extends PluginPanel
*/
if (SKILLS.contains(skill))
{
long experience = result.getSkill(skill).getExperience();
long experience = 0;
if (skill != null)
{
experience = result.getSkill(skill).getExperience();
}
if (experience >= 0)
{
int currentXp = (int) experience;

View File

@@ -134,14 +134,6 @@ public class HunterPlugin extends Plugin
* ------------------------------------------------------------------------------
*/
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
// If player is right next to "object" trap assume that player placed the trap
if (localPlayer.getWorldLocation().distanceTo(trapLocation) <= 2)

View File

@@ -53,17 +53,14 @@ public class BabyHydraIndicatorOverlay extends Overlay
@Override
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());
if (val != 0)
{
int val = plugin.getHydras().get(plugin.getHydra().getIndex());
if (val != 0)
{
panelComponent.getChildren().clear();
panelComponent.getChildren().add(LineComponent.builder().right(Integer.toString(val)).build());
return panelComponent.render(graphics);
}
panelComponent.getChildren().clear();
panelComponent.getChildren().add(LineComponent.builder().right(Integer.toString(val)).build());
return panelComponent.render(graphics);
}
}
return null;

View File

@@ -65,52 +65,49 @@ public class BabyHydraOverlay extends Overlay
{
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());
if (val != 0)
{
int val = plugin.getHydras().get(hydra.getIndex());
if (val != 0)
if (plugin.isBoldText())
{
if (plugin.isBoldText())
{
graphics.setFont(FontManager.getRunescapeBoldFont());
}
if (plugin.getHydraattacks().containsKey(hydra.getIndex()))
{
int attack = plugin.getHydraattacks().get(hydra.getIndex());
graphics.setFont(FontManager.getRunescapeBoldFont());
}
if (plugin.getHydraattacks().containsKey(hydra.getIndex()))
{
int attack = plugin.getHydraattacks().get(hydra.getIndex());
Point textLocation = hydra.getCanvasTextLocation(graphics, "TEMP!!", hydra.getLogicalHeight() + 100);
Point textLocation = hydra.getCanvasTextLocation(graphics, "TEMP!!", hydra.getLogicalHeight() + 100);
if (textLocation != null && attack == 8261)
if (textLocation != null && attack == 8261)
{
if (val == 3)
{
if (val == 3)
{
OverlayUtil.renderTextLocation(graphics, textLocation, "MAGE", Color.BLUE);
}
else
{
OverlayUtil.renderTextLocation(graphics, textLocation, "RANGE", Color.GREEN);
}
OverlayUtil.renderTextLocation(graphics, textLocation, "MAGE", Color.BLUE);
}
else if (textLocation != null && attack == 8262)
else
{
if (val == 3)
{
OverlayUtil.renderTextLocation(graphics, textLocation, "RANGE", Color.GREEN);
}
else
{
OverlayUtil.renderTextLocation(graphics, textLocation, "MAGE", Color.BLUE);
}
OverlayUtil.renderTextLocation(graphics, textLocation, "RANGE", Color.GREEN);
}
}
Point hydraPoint = hydra.getCanvasTextLocation(graphics, Integer.toString(val), hydra.getLogicalHeight() + 40);
if (hydraPoint != null)
else if (textLocation != null && attack == 8262)
{
OverlayUtil.renderTextLocation(graphics, hydraPoint, Integer.toString(val), Color.WHITE);
if (val == 3)
{
OverlayUtil.renderTextLocation(graphics, textLocation, "RANGE", Color.GREEN);
}
else
{
OverlayUtil.renderTextLocation(graphics, textLocation, "MAGE", Color.BLUE);
}
}
}
Point hydraPoint = hydra.getCanvasTextLocation(graphics, Integer.toString(val), hydra.getLogicalHeight() + 40);
if (hydraPoint != null)
{
OverlayUtil.renderTextLocation(graphics, hydraPoint, Integer.toString(val), Color.WHITE);
}
}
}

View File

@@ -159,15 +159,9 @@ public class BabyHydraPlugin extends Plugin
public void onNpcSpawned(NpcSpawned event)
{
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);
}
}
@@ -175,13 +169,10 @@ public class BabyHydraPlugin extends Plugin
public void onNpcDespawned(NpcDespawned event)
{
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());
hydraattacks.remove(hydra.getIndex());
}
hydras.remove(hydra.getIndex());
hydraattacks.remove(hydra.getIndex());
}
}

View File

@@ -47,8 +47,8 @@ public class BabyHydraPrayOverlay extends Overlay
private final BabyHydraPlugin plugin;
private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150);
private BufferedImage PRAY_MAGE;
private BufferedImage PRAY_RANGED;
private BufferedImage prayMage;
private BufferedImage prayRanged;
private final PanelComponent imagePanelComponent = new PanelComponent();
@Inject
@@ -69,71 +69,65 @@ public class BabyHydraPrayOverlay extends Overlay
@Override
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());
if (val != 0 && plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
{
int val = plugin.getHydras().get(plugin.getHydra().getIndex());
if (val != 0)
int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex());
if (attack == 8261)
{
if (plugin.getHydraattacks().containsKey(plugin.getHydra().getIndex()))
if (val == 3)
{
int attack = plugin.getHydraattacks().get(plugin.getHydra().getIndex());
if (attack == 8261)
{
if (val == 3)
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_MAGE));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(prayMage));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
else
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_RANGED));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
else
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(prayRanged));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
}
else if (attack == 8262)
{
if (val == 3)
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_RANGED));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
}
else if (attack == 8262)
{
if (val == 3)
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(prayRanged));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MISSILES)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
else
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(PRAY_MAGE));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
else
{
imagePanelComponent.getChildren().clear();
imagePanelComponent.getChildren().add(new ImageComponent(prayMage));
imagePanelComponent.setBackgroundColor(client.isPrayerActive(Prayer.PROTECT_FROM_MAGIC)
? ComponentConstants.STANDARD_BACKGROUND_COLOR
: NOT_ACTIVATED_BACKGROUND_COLOR);
return imagePanelComponent.render(graphics);
}
}
return imagePanelComponent.render(graphics);
}
}
}

View File

@@ -27,100 +27,18 @@ package net.runelite.client.plugins.idlenotifier;
import com.google.inject.Provides;
import java.awt.TrayIcon;
//import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import javax.inject.Inject;
//import javax.sound.sampled.LineUnavailableException;
//import javax.sound.sampled.UnsupportedAudioFileException;
import javax.inject.Singleton;
import lombok.AccessLevel;
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.AnimationID;
import static net.runelite.api.AnimationID.COOKING_FIRE;
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 static net.runelite.api.AnimationID.*;
import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.GameState;
@@ -135,12 +53,13 @@ import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits;
import net.runelite.api.WorldType;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
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.util.PvPUtil;
//import java.io.IOException;
//import javax.sound.sampled.LineUnavailableException;
//import javax.sound.sampled.UnsupportedAudioFileException;
@PluginDescriptor(
name = "Idle Notifier",
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
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
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
@@ -362,22 +283,14 @@ public class IdleNotifierPlugin extends Plugin
private void onPlayerSpawned(PlayerSpawned event)
{
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)
&& !client.isClanMember(p.getName()))
{
if (p != null)
{
if (p != client.getLocalPlayer())
{
if (PvPUtil.isAttackable(client, p) && !client.isFriended(p.getName(), false)
&& !client.isClanMember(p.getName()))
{
String playerName = p.getName();
int combat = p.getCombatLevel();
notifier.notify("PK'er warning! A level " + combat + " player named " + playerName +
" appeared!", TrayIcon.MessageType.WARNING);
}
}
}
String playerName = p.getName();
int combat = p.getCombatLevel();
notifier.notify("PK'er warning! A level " + combat + " player named " + playerName +
" appeared!", TrayIcon.MessageType.WARNING);
}
}

View File

@@ -29,7 +29,9 @@ public class ImplingCounterOverlay extends Overlay
public Dimension render(Graphics2D graphics)
{
if (!plugin.isShowSpawn() || plugin.getImplings().isEmpty())
{
return null;
}
panelComponent.getChildren().clear();

View File

@@ -41,7 +41,7 @@ public class InfernoNPC
RANDOM("Random", Color.ORANGE);
@Getter(AccessLevel.PACKAGE)
private String name = "";
private String name;
@Getter(AccessLevel.PACKAGE)
private Color color;

View File

@@ -88,7 +88,7 @@ public class InfernoOverlay extends Overlay
}
// 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));
Point textLocation = actor.getNpc().getCanvasTextLocation(graphics, text, actor.textLocHeight + 40);

View File

@@ -118,7 +118,7 @@ public class InfernoPlugin extends Plugin
@Getter(AccessLevel.PACKAGE)
private int currentWaveNumber;
private List<Actor> waveMonsters;
private final List<Actor> waveMonsters;
public InfernoPlugin()
{

View File

@@ -147,12 +147,9 @@ public class InfoPanel extends PluginPanel
emailLabel.enableAutoLinkHandler(false);
emailLabel.addHyperlinkListener(e ->
{
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null)
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null && e.getURL().toString().equals(RUNELITE_LOGIN))
{
if (e.getURL().toString().equals(RUNELITE_LOGIN))
{
executor.execute(sessionManager::login);
}
executor.execute(sessionManager::login);
}
});

View File

@@ -68,18 +68,15 @@ public class JRichTextPane extends JEditorPane
{
linkHandler = e ->
{
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null)
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType()) && e.getURL() != null && Desktop.isDesktopSupported())
{
if (Desktop.isDesktopSupported())
try
{
try
{
Desktop.getDesktop().browse(e.getURL().toURI());
}
catch (URISyntaxException | IOException ex)
{
log.warn("Error opening link", ex);
}
Desktop.getDesktop().browse(e.getURL().toURI());
}
catch (URISyntaxException | IOException ex)
{
log.warn("Error opening link", ex);
}
}
};

View File

@@ -34,7 +34,7 @@ import net.runelite.client.input.KeyListener;
import net.runelite.client.input.MouseAdapter;
import net.runelite.client.input.MouseWheelListener;
public class InstanceMapInputListener extends MouseAdapter implements KeyListener, MouseWheelListener
class InstanceMapInputListener extends MouseAdapter implements KeyListener, MouseWheelListener
{
@Inject
private InstanceMapPlugin plugin;

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