Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-11-17 04:46:44 +01:00
27 changed files with 195 additions and 106 deletions

View File

@@ -0,0 +1,96 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<ruleset name="RuneLite"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
RuneLite PMD ruleset
</description>
<!-- best practices -->
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
<rule ref="category/java/bestpractices.xml/DoubleBraceInitialization"/>
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
<rule ref="category/java/bestpractices.xml/MissingOverride"/>
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
<properties>
<property name="ignoredAnnotations"
value="net.runelite.client.eventbus.Subscribe|com.google.inject.Provides"/>
</properties>
</rule>
<rule ref="category/java/bestpractices.xml/UseTryWithResources"/>
<rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean"/>
<!-- code style -->
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
<rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
<rule ref="category/java/codestyle.xml/ExtendsObject"/>
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
<rule ref="category/java/codestyle.xml/PackageCase"/>
<rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
<rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>
<!-- design -->
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
<rule ref="category/java/design.xml/ImmutableField"/>
<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
<rule ref="category/java/design.xml/SimplifyConditional"/>
<rule ref="category/java/design.xml/UselessOverridingMethod"/>
<!-- error prone -->
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
<rule ref="category/java/errorprone.xml/DontImportSun"/>
<rule ref="category/java/errorprone.xml/EmptyFinallyBlock"/>
<rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
<rule ref="category/java/errorprone.xml/EmptyInitializer"/>
<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
<rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
<!-- performance -->
<rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
</ruleset>

View File

@@ -102,7 +102,7 @@ public class ClientThread implements Executor
{
assert client.isClientThread();
Iterator<BooleanSupplier> ir = invokes.iterator();
for (; ir.hasNext(); )
while (ir.hasNext())
{
BooleanSupplier r = ir.next();
boolean remove = true;

View File

@@ -49,6 +49,7 @@ public class ModifierlessKeybind extends Keybind
* KeyReleased event this returns if the event is this hotkey being
* released
*/
@Override
public boolean matches(KeyEvent e)
{
return matches(e, true);

View File

@@ -283,11 +283,11 @@ public class ItemManager
* */
public int getItemPrice(int itemID, boolean ignoreUntradeableMap)
{
if (itemID == ItemID.COINS_995)
if (itemID == COINS_995)
{
return 1;
}
if (itemID == ItemID.PLATINUM_TOKEN)
if (itemID == PLATINUM_TOKEN)
{
return 1000;
}
@@ -527,7 +527,7 @@ public class ItemManager
*/
private BufferedImage loadItemOutline(final int itemId, final int itemQuantity, final Color outlineColor)
{
final Sprite itemSprite = client.createItemSprite(itemId, itemQuantity, 1, 0, 0, false, Constants.CLIENT_DEFAULT_ZOOM);
final Sprite itemSprite = client.createItemSprite(itemId, itemQuantity, 1, 0, 0, false, CLIENT_DEFAULT_ZOOM);
return itemSprite.toBufferedOutline(outlineColor);
}

View File

@@ -40,7 +40,6 @@ public class SkillIconManager
public BufferedImage getSkillImage(Skill skill, boolean small)
{
int skillIdx = skill.ordinal() + (small ? Skill.values().length : 0);
BufferedImage skillImage;
if (imgCache[skillIdx] != null)
{
@@ -50,7 +49,7 @@ public class SkillIconManager
String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/")
+ skill.getName().toLowerCase() + ".png";
log.debug("Loading skill icon from {}", skillIconPath);
skillImage = ImageUtil.getResourceStreamFromClass(getClass(), skillIconPath);
BufferedImage skillImage = ImageUtil.getResourceStreamFromClass(getClass(), skillIconPath);
imgCache[skillIdx] = skillImage;
return skillImage;

View File

@@ -47,6 +47,7 @@ import net.runelite.api.widgets.WidgetTextAlignment;
import net.runelite.api.widgets.WidgetType;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.JagexColors;
@Singleton
public class ChatboxItemSearch extends ChatboxTextInput
@@ -141,7 +142,7 @@ public class ChatboxItemSearch extends ChatboxTextInput
item.setOriginalY(y + FONT_SIZE * 2);
item.setOriginalHeight(ICON_HEIGHT);
item.setOriginalWidth(ICON_WIDTH);
item.setName("<col=ff9040>" + itemDefinition.getName());
item.setName(JagexColors.MENU_TARGET_TAG + itemDefinition.getName());
item.setItemId(itemDefinition.getId());
item.setItemQuantity(10000);
item.setItemQuantityMode(ItemQuantityMode.NEVER);

View File

@@ -48,7 +48,7 @@ class ClientConfigLoader
final RSConfig config = new RSConfig();
try (final Response response = okHttpClient.newCall(request).execute())
try (Response response = okHttpClient.newCall(request).execute())
{
if (!response.isSuccessful())
{

View File

@@ -54,7 +54,8 @@ public class JagexColors
/*
* Colors relating to right-click menus.
*/
public static final Color MENU_TARGET = new Color(255, 144, 64);
public static final Color MENU_TARGET = new Color(0xFF9040);
public static final String MENU_TARGET_TAG = "<col=ff9040>";
/*
* Colors relating to tooltips.

View File

@@ -72,7 +72,6 @@ public class MaterialTab extends JLabel
{
super(string);
/* The tab's containing group */
this.content = content;
if (selected)

View File

@@ -34,7 +34,20 @@ import java.util.Set;
import lombok.AccessLevel;
import lombok.Setter;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.*;
import static net.runelite.api.widgets.WidgetID.BANK_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.BANK_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.DEPOSIT_BOX_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.EQUIPMENT_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.EQUIPMENT_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.GRAND_EXCHANGE_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.GUIDE_PRICES_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.SEED_VAULT_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.SHOP_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.DUEL_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.DUEL_INVENTORY_OTHER_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.PLAYER_TRADE_SCREEN_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.PLAYER_TRADE_INVENTORY_GROUP_ID;
import static net.runelite.api.widgets.WidgetInfo.BANK_CONTENT_CONTAINER;
import static net.runelite.api.widgets.WidgetInfo.BANK_TAB_CONTAINER;
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
@@ -129,7 +142,11 @@ public abstract class WidgetItemOverlay extends Overlay
GUIDE_PRICES_INVENTORY_GROUP_ID,
EQUIPMENT_INVENTORY_GROUP_ID,
INVENTORY_GROUP_ID,
SEED_VAULT_INVENTORY_GROUP_ID);
SEED_VAULT_INVENTORY_GROUP_ID,
DUEL_INVENTORY_GROUP_ID,
DUEL_INVENTORY_OTHER_GROUP_ID,
PLAYER_TRADE_SCREEN_GROUP_ID,
PLAYER_TRADE_INVENTORY_GROUP_ID);
}
protected void showOnBank()

View File

@@ -45,7 +45,7 @@ public class WildcardMatcher
}
else
{
matcher.appendReplacement(sb, "\\\\Q" + matcher.group(0) + "\\\\E");
matcher.appendReplacement(sb, Matcher.quoteReplacement(Pattern.quote(matcher.group(0))));
}
}

View File

@@ -4720,7 +4720,6 @@
],
"cyan crystal": [
6643,
22366,
23779
],
"blue crystal": [
@@ -8292,10 +8291,6 @@
24890,
24894
],
"dark altar": [
20619,
22778
],
"occult altar": [
20620,
20621,
@@ -9306,10 +9301,6 @@
24365,
24366
],
"twisted adamant trophy": [
24376,
25046
],
"twisted hat": [
24387,
24397,

View File

@@ -533,7 +533,13 @@ LABEL416:
LABEL430:
jump LABEL445
LABEL431:
iload 9 ; The id of the messageNode of the message being built
sconst ""
sconst "addTimestamp"
runelite_callback
pop_int ; pop message id
sload 11
join_string 2
iload 7
iload 8
iconst 10616891

View File

@@ -39,5 +39,6 @@ public class WildcardMatcherTest
assertFalse(matches("Abyssal whip", "Adamant dagger"));
assertTrue(matches("rune*", "Runeite Ore"));
assertTrue(matches("Abyssal whip", "Abyssal whip"));
assertTrue(matches("string $ with special character", "string $ with special character"));
}
}