Merge pull request #3172 from open-osrs/upstream-2504

This commit is contained in:
Owain van Brakel
2022-04-25 11:06:01 +02:00
committed by GitHub
33 changed files with 147 additions and 93 deletions

View File

@@ -420,7 +420,6 @@ public interface Client extends OAuthApi, GameEngine
* <p> * <p>
* (getLocalPlayerIndex returns the local index, useful for menus/interacting) * (getLocalPlayerIndex returns the local index, useful for menus/interacting)
*/ */
@Nullable
Player getLocalPlayer(); Player getLocalPlayer();
int getLocalPlayerIndex(); int getLocalPlayerIndex();

View File

@@ -452,4 +452,10 @@ public final class ScriptID
@ScriptArguments(integer = 6) @ScriptArguments(integer = 6)
public static final int INVENTORY_DRAWITEM = 6011; public static final int INVENTORY_DRAWITEM = 6011;
/**
* Initializes the trade interface
*/
@ScriptArguments(integer = 6)
public static final int TRADE_MAIN_INIT = 755;
} }

View File

@@ -188,6 +188,7 @@ public final class WidgetID
public static final int GROUP_STORAGE_INVENTORY_GROUP_ID = 725; public static final int GROUP_STORAGE_INVENTORY_GROUP_ID = 725;
public static final int GROUP_STORAGE_GROUP_ID = 724; public static final int GROUP_STORAGE_GROUP_ID = 724;
public static final int WILDERNESS_LOOT_CHEST = 742; public static final int WILDERNESS_LOOT_CHEST = 742;
public static final int TRADE_WINDOW_GROUP_ID = 335;
static class WorldMap static class WorldMap
{ {
@@ -1367,4 +1368,9 @@ public final class WidgetID
static final int HEADER = 1; static final int HEADER = 1;
static final int MEMBERS = 6; static final int MEMBERS = 6;
} }
static class Trade
{
static final int HEADER = 31;
}
} }

View File

@@ -930,6 +930,8 @@ public enum WidgetInfo
SHOP_ITEMS_CONTAINER(WidgetID.SHOP_GROUP_ID, WidgetID.Shop.ITEMS_CONTAINER), SHOP_ITEMS_CONTAINER(WidgetID.SHOP_GROUP_ID, WidgetID.Shop.ITEMS_CONTAINER),
POH_TREASURE_CHEST_INVENTORY_CONTAINER(WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID, 0), POH_TREASURE_CHEST_INVENTORY_CONTAINER(WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID, 0),
TRADE_WINDOW_HEADER(WidgetID.TRADE_WINDOW_GROUP_ID, WidgetID.Trade.HEADER),
; ;
private final int groupId; private final int groupId;

View File

@@ -53,13 +53,14 @@
<!-- code style --> <!-- code style -->
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/> <rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/> <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/ExtendsObject"/>
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/> <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/> <rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
<rule ref="category/java/codestyle.xml/PackageCase"/> <rule ref="category/java/codestyle.xml/PackageCase"/>
<rule ref="category/java/codestyle.xml/UnnecessaryCast"/> <rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/> <rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
<rule ref="category/java/codestyle.xml/UnnecessaryImport" />
<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/> <rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
<rule ref="category/java/codestyle.xml/UseDiamondOperator"/> <rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/> <rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>
@@ -84,18 +85,20 @@
<rule ref="category/java/errorprone.xml/EmptyIfStmt"/> <rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
<rule ref="category/java/errorprone.xml/EmptyInitializer"/> <rule ref="category/java/errorprone.xml/EmptyInitializer"/>
<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/> <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/InstantiationToGetClass"/>
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/> <rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/> <rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/> <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/> <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/> <rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
<!-- performance --> <!-- performance -->
<rule ref="category/java/performance.xml/AppendCharacterWithChar"/> <rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/> <rule ref="category/java/performance.xml/ConsecutiveLiteralAppends">
<properties>
<property name="threshold" value="2"/>
</properties>
</rule>
<rule ref="category/java/performance.xml/InefficientStringBuffering"/> <rule ref="category/java/performance.xml/InefficientStringBuffering"/>
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/> <rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
</ruleset> </ruleset>

View File

@@ -34,7 +34,7 @@ public class ChatMessageBuilder
public ChatMessageBuilder append(final ChatColorType type) public ChatMessageBuilder append(final ChatColorType type)
{ {
builder.append("<col").append(type.name()).append(">"); builder.append("<col").append(type.name()).append('>');
return this; return this;
} }

View File

@@ -447,7 +447,7 @@ class WidgetInspector extends DevToolsFrame
picker = parent.createChild(-1, WidgetType.GRAPHIC); picker = parent.createChild(-1, WidgetType.GRAPHIC);
log.info("Picker is {}.{} [{}]", WidgetInfo.TO_GROUP(picker.getId()), WidgetInfo.TO_CHILD(picker.getId()), picker.getIndex()); log.info("Picker is {}.{} [{}]", TO_GROUP(picker.getId()), TO_CHILD(picker.getId()), picker.getIndex());
picker.setSpriteId(SpriteID.MOBILE_FINGER_ON_INTERFACE); picker.setSpriteId(SpriteID.MOBILE_FINGER_ON_INTERFACE);
picker.setOriginalWidth(15); picker.setOriginalWidth(15);
@@ -521,7 +521,7 @@ class WidgetInspector extends DevToolsFrame
{ {
continue; continue;
} }
String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1()); String name = TO_GROUP(entry.getParam1()) + "." + TO_CHILD(entry.getParam1());
if (entry.getParam0() != -1) if (entry.getParam0() != -1)
{ {

View File

@@ -445,7 +445,7 @@ public class FishingPlugin extends Plugin
if (seconds < 10) if (seconds < 10)
{ {
trawlerText.append("0"); trawlerText.append('0');
} }
trawlerText.append(seconds); trawlerText.append(seconds);

View File

@@ -41,7 +41,6 @@ import jogamp.opengl.x11.glx.X11GLXContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.plugins.gpu.template.Template; import net.runelite.client.plugins.gpu.template.Template;
import net.runelite.client.util.OSType; import net.runelite.client.util.OSType;
import org.jocl.CL;
import static org.jocl.CL.*; import static org.jocl.CL.*;
import org.jocl.CLException; import org.jocl.CLException;
import org.jocl.Pointer; import org.jocl.Pointer;
@@ -96,7 +95,7 @@ class OpenCLManager
void init(GL4 gl) void init(GL4 gl)
{ {
CL.setExceptionsEnabled(true); setExceptionsEnabled(true);
switch (OSType.getOSType()) switch (OSType.getOSType())
{ {
@@ -121,55 +120,55 @@ class OpenCLManager
{ {
if (programUnordered != null) if (programUnordered != null)
{ {
CL.clReleaseProgram(programUnordered); clReleaseProgram(programUnordered);
programUnordered = null; programUnordered = null;
} }
if (programSmall != null) if (programSmall != null)
{ {
CL.clReleaseProgram(programSmall); clReleaseProgram(programSmall);
programSmall = null; programSmall = null;
} }
if (programLarge != null) if (programLarge != null)
{ {
CL.clReleaseProgram(programLarge); clReleaseProgram(programLarge);
programLarge = null; programLarge = null;
} }
if (kernelUnordered != null) if (kernelUnordered != null)
{ {
CL.clReleaseKernel(kernelUnordered); clReleaseKernel(kernelUnordered);
kernelUnordered = null; kernelUnordered = null;
} }
if (kernelSmall != null) if (kernelSmall != null)
{ {
CL.clReleaseKernel(kernelSmall); clReleaseKernel(kernelSmall);
kernelSmall = null; kernelSmall = null;
} }
if (kernelLarge != null) if (kernelLarge != null)
{ {
CL.clReleaseKernel(kernelLarge); clReleaseKernel(kernelLarge);
kernelLarge = null; kernelLarge = null;
} }
if (commandQueue != null) if (commandQueue != null)
{ {
CL.clReleaseCommandQueue(commandQueue); clReleaseCommandQueue(commandQueue);
commandQueue = null; commandQueue = null;
} }
if (context != null) if (context != null)
{ {
CL.clReleaseContext(context); clReleaseContext(context);
context = null; context = null;
} }
if (device != null) if (device != null)
{ {
CL.clReleaseDevice(device); clReleaseDevice(device);
device = null; device = null;
} }
} }

View File

@@ -829,7 +829,7 @@ public class GrandExchangePlugin extends Plugin
if (resetTime != null) if (resetTime != null)
{ {
Duration remaining = Duration.between(Instant.now(), resetTime); Duration remaining = Duration.between(Instant.now(), resetTime);
sb.append(" (").append(DurationFormatUtils.formatDuration(remaining.toMillis(), "H:mm")).append(")"); sb.append(" (").append(DurationFormatUtils.formatDuration(remaining.toMillis(), "H:mm")).append(')');
} }
} }

View File

@@ -246,7 +246,7 @@ public class GroundItemsOverlay extends Overlay
{ {
itemStringBuilder.append(" (") itemStringBuilder.append(" (")
.append(QuantityFormatter.quantityToStackSize(item.getQuantity())) .append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
.append(")"); .append(')');
} }
} }

View File

@@ -663,7 +663,7 @@ public class GroundItemsPlugin extends Plugin
{ {
notificationStringBuilder.append(" (") notificationStringBuilder.append(" (")
.append(QuantityFormatter.quantityToStackSize(item.getQuantity())) .append(QuantityFormatter.quantityToStackSize(item.getQuantity()))
.append(")"); .append(')');
} }
} }

View File

@@ -173,7 +173,7 @@ public class ItemStatOverlay extends Overlay
Duration highestDuration = durationRange.getHighestDuration(); Duration highestDuration = durationRange.getHighestDuration();
if (lowestDuration != highestDuration) if (lowestDuration != highestDuration)
{ {
sb.append("~"); sb.append('~');
sb.append(DurationFormatUtils.formatDuration(highestDuration.toMillis(), "m:ss")); sb.append(DurationFormatUtils.formatDuration(highestDuration.toMillis(), "m:ss"));
} }
} }
@@ -381,7 +381,7 @@ public class ItemStatOverlay extends Overlay
{ {
if (config.relative()) if (config.relative())
{ {
b.append("/"); b.append('/');
} }
b.append(c.getFormattedTheoretical()); b.append(c.getFormattedTheoretical());
} }
@@ -397,9 +397,9 @@ public class ItemStatOverlay extends Overlay
if (config.absolute() && (config.relative() || config.theoretical())) if (config.absolute() && (config.relative() || config.theoretical()))
{ {
b.append(")"); b.append(')');
} }
b.append(" ").append(c.getStat().getName()); b.append(' ').append(c.getStat().getName());
b.append("</br>"); b.append("</br>");
return b.toString(); return b.toString();

View File

@@ -106,7 +106,7 @@ class Bookcase
b.append("Center"); b.append("Center");
} }
b.append(" "); b.append(' ');
switch (location.getPlane()) switch (location.getPlane())
{ {
@@ -123,7 +123,7 @@ class Bookcase
if (KourendLibraryPlugin.debug) if (KourendLibraryPlugin.debug)
{ {
b.append(" ").append(index.stream().map(Object::toString).collect(Collectors.joining(", "))); b.append(' ').append(index.stream().map(Object::toString).collect(Collectors.joining(", ")));
} }
return b.toString(); return b.toString();
} }

View File

@@ -79,7 +79,7 @@ class Library
Library() Library()
{ {
populateBooks(); populateBooks();
step = byIndex.size() / Book.values().length; step = byIndex.size() / values().length;
reset(); reset();
} }

View File

@@ -29,22 +29,17 @@ import java.awt.image.BufferedImage;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import lombok.Getter;
import lombok.Setter;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.Timer; import net.runelite.client.ui.overlay.infobox.Timer;
class AggressionTimer extends Timer class AggressionTimer extends Timer
{ {
@Getter private final NpcAggroAreaPlugin plugin;
@Setter
private boolean visible;
AggressionTimer(Duration duration, BufferedImage image, Plugin plugin, boolean visible) AggressionTimer(Duration duration, BufferedImage image, NpcAggroAreaPlugin plugin)
{ {
super(duration.toMillis(), ChronoUnit.MILLIS, image, plugin); super(duration.toMillis(), ChronoUnit.MILLIS, image, plugin);
setTooltip("Time until NPCs become unaggressive"); setTooltip("Time until NPCs become unaggressive");
this.visible = visible; this.plugin = plugin;
} }
@Override @Override
@@ -63,6 +58,6 @@ class AggressionTimer extends Timer
@Override @Override
public boolean render() public boolean render()
{ {
return visible && super.render(); return plugin.shouldDisplayTimer() && super.render();
} }
} }

View File

@@ -84,8 +84,7 @@ class NpcAggroAreaOverlay extends Overlay
} }
Color outlineColor = config.unaggroAreaColor(); Color outlineColor = config.unaggroAreaColor();
AggressionTimer timer = plugin.getCurrentTimer(); if (outlineColor == null || (plugin.getEndTime() != null && Instant.now().isBefore(plugin.getEndTime())))
if (outlineColor == null || timer == null || Instant.now().compareTo(timer.getEndTime()) < 0)
{ {
outlineColor = config.aggroAreaColor(); outlineColor = config.aggroAreaColor();
} }

View File

@@ -82,7 +82,7 @@ public class NpcAggroAreaPlugin extends Plugin
private static final int SAFE_AREA_RADIUS = 10; private static final int SAFE_AREA_RADIUS = 10;
private static final int UNKNOWN_AREA_RADIUS = SAFE_AREA_RADIUS * 2; private static final int UNKNOWN_AREA_RADIUS = SAFE_AREA_RADIUS * 2;
private static final int AGGRESSIVE_TIME_SECONDS = 600; private static final Duration AGGRESSIVE_TIME_DURATION = Duration.ofSeconds(600);
private static final Splitter NAME_SPLITTER = Splitter.on(',').omitEmptyStrings().trimResults(); private static final Splitter NAME_SPLITTER = Splitter.on(',').omitEmptyStrings().trimResults();
private static final WorldArea WILDERNESS_ABOVE_GROUND = new WorldArea(2944, 3523, 448, 448, 0); private static final WorldArea WILDERNESS_ABOVE_GROUND = new WorldArea(2944, 3523, 448, 448, 0);
private static final WorldArea WILDERNESS_UNDERGROUND = new WorldArea(2944, 9918, 320, 442, 0); private static final WorldArea WILDERNESS_UNDERGROUND = new WorldArea(2944, 9918, 320, 442, 0);
@@ -124,7 +124,7 @@ public class NpcAggroAreaPlugin extends Plugin
private boolean active; private boolean active;
@Getter @Getter
private AggressionTimer currentTimer; private Instant endTime;
private WorldPoint lastPlayerLocation; private WorldPoint lastPlayerLocation;
private WorldPoint previousUnknownCenter; private WorldPoint previousUnknownCenter;
@@ -156,7 +156,7 @@ public class NpcAggroAreaPlugin extends Plugin
overlayManager.remove(notWorkingOverlay); overlayManager.remove(notWorkingOverlay);
Arrays.fill(safeCenters, null); Arrays.fill(safeCenters, null);
lastPlayerLocation = null; lastPlayerLocation = null;
currentTimer = null; endTime = null;
loggingIn = false; loggingIn = false;
npcNamePatterns = null; npcNamePatterns = null;
active = false; active = false;
@@ -193,16 +193,6 @@ public class NpcAggroAreaPlugin extends Plugin
coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2f; coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2f;
} }
private void reevaluateActive()
{
if (currentTimer != null)
{
currentTimer.setVisible(active && config.showTimer());
}
calculateLinesToDisplay();
}
private void calculateLinesToDisplay() private void calculateLinesToDisplay()
{ {
if (!active || !config.showAreaLines()) if (!active || !config.showAreaLines())
@@ -227,23 +217,29 @@ public class NpcAggroAreaPlugin extends Plugin
private void removeTimer() private void removeTimer()
{ {
infoBoxManager.removeInfoBox(currentTimer); infoBoxManager.removeIf(t -> t instanceof AggressionTimer);
currentTimer = null; endTime = null;
notifyOnce = false; notifyOnce = false;
} }
private void createTimer(Duration duration) private void createTimer(Duration duration)
{ {
removeTimer(); removeTimer();
BufferedImage image = itemManager.getImage(ItemID.ENSOULED_DEMON_HEAD); endTime = Instant.now().plus(duration);
currentTimer = new AggressionTimer(duration, image, this, active && config.showTimer());
infoBoxManager.addInfoBox(currentTimer);
notifyOnce = true; notifyOnce = true;
if (duration.isNegative())
{
return;
}
BufferedImage image = itemManager.getImage(ItemID.ENSOULED_DEMON_HEAD);
infoBoxManager.addInfoBox(new AggressionTimer(duration, image, this));
} }
private void resetTimer() private void resetTimer()
{ {
createTimer(Duration.ofSeconds(AGGRESSIVE_TIME_SECONDS)); createTimer(AGGRESSIVE_TIME_DURATION);
} }
private static boolean isInWilderness(WorldPoint location) private static boolean isInWilderness(WorldPoint location)
@@ -301,7 +297,7 @@ public class NpcAggroAreaPlugin extends Plugin
} }
} }
reevaluateActive(); calculateLinesToDisplay();
} }
private void recheckActive() private void recheckActive()
@@ -326,7 +322,7 @@ public class NpcAggroAreaPlugin extends Plugin
{ {
WorldPoint newLocation = client.getLocalPlayer().getWorldLocation(); WorldPoint newLocation = client.getLocalPlayer().getWorldLocation();
if (active && currentTimer != null && currentTimer.cull() && notifyOnce) if (active && notifyOnce && Instant.now().isAfter(endTime))
{ {
if (config.notifyExpire()) if (config.notifyExpire())
{ {
@@ -387,12 +383,6 @@ public class NpcAggroAreaPlugin extends Plugin
case "npcUnaggroAlwaysActive": case "npcUnaggroAlwaysActive":
recheckActive(); recheckActive();
break; break;
case "npcUnaggroShowTimer":
if (currentTimer != null)
{
currentTimer.setVisible(active && config.showTimer());
}
break;
case "npcUnaggroCollisionDetection": case "npcUnaggroCollisionDetection":
case "npcUnaggroShowAreaLines": case "npcUnaggroShowAreaLines":
calculateLinesToDisplay(); calculateLinesToDisplay();
@@ -404,6 +394,11 @@ public class NpcAggroAreaPlugin extends Plugin
} }
} }
boolean shouldDisplayTimer()
{
return active && config.showTimer();
}
private void loadConfig() private void loadConfig()
{ {
safeCenters[0] = configManager.getConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER1, WorldPoint.class); safeCenters[0] = configManager.getConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER1, WorldPoint.class);
@@ -411,7 +406,7 @@ public class NpcAggroAreaPlugin extends Plugin
lastPlayerLocation = configManager.getConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_LOCATION, WorldPoint.class); lastPlayerLocation = configManager.getConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_LOCATION, WorldPoint.class);
Duration timeLeft = configManager.getConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_DURATION, Duration.class); Duration timeLeft = configManager.getConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_DURATION, Duration.class);
if (timeLeft != null && !timeLeft.isNegative()) if (timeLeft != null)
{ {
createTimer(timeLeft); createTimer(timeLeft);
} }
@@ -427,7 +422,7 @@ public class NpcAggroAreaPlugin extends Plugin
private void saveConfig() private void saveConfig()
{ {
if (safeCenters[0] == null || safeCenters[1] == null || lastPlayerLocation == null || currentTimer == null) if (safeCenters[0] == null || safeCenters[1] == null || lastPlayerLocation == null || endTime == null)
{ {
resetConfig(); resetConfig();
} }
@@ -436,7 +431,7 @@ public class NpcAggroAreaPlugin extends Plugin
configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER1, safeCenters[0]); configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER1, safeCenters[0]);
configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER2, safeCenters[1]); configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_CENTER2, safeCenters[1]);
configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_LOCATION, lastPlayerLocation); configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_LOCATION, lastPlayerLocation);
configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_DURATION, Duration.between(Instant.now(), currentTimer.getEndTime())); configManager.setConfiguration(NpcAggroAreaConfig.CONFIG_GROUP, NpcAggroAreaConfig.CONFIG_DURATION, Duration.between(Instant.now(), endTime));
} }
} }
@@ -486,6 +481,7 @@ public class NpcAggroAreaPlugin extends Plugin
safeCenters[0] = null; safeCenters[0] = null;
safeCenters[1] = null; safeCenters[1] = null;
lastPlayerLocation = null; lastPlayerLocation = null;
endTime = null;
break; break;
} }
} }

View File

@@ -42,12 +42,17 @@ import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION; import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION; import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION;
import static net.runelite.api.MenuAction.RUNELITE_PLAYER; import static net.runelite.api.MenuAction.RUNELITE_PLAYER;
import static net.runelite.api.MenuAction.WIDGET_TARGET_ON_PLAYER;
import static net.runelite.api.MenuAction.WALK; import static net.runelite.api.MenuAction.WALK;
import static net.runelite.api.MenuAction.WIDGET_TARGET_ON_PLAYER;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.ScriptID;
import net.runelite.api.clan.ClanTitle; import net.runelite.api.clan.ClanTitle;
import net.runelite.api.events.ClientTick; import net.runelite.api.events.ClientTick;
import net.runelite.api.events.ScriptPostFired;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ChatIconManager; import net.runelite.client.game.ChatIconManager;
@@ -63,6 +68,8 @@ import net.runelite.client.util.ColorUtil;
) )
public class PlayerIndicatorsPlugin extends Plugin public class PlayerIndicatorsPlugin extends Plugin
{ {
private static final String TRADING_WITH_TEXT = "Trading with: ";
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@@ -87,6 +94,9 @@ public class PlayerIndicatorsPlugin extends Plugin
@Inject @Inject
private ChatIconManager chatIconManager; private ChatIconManager chatIconManager;
@Inject
private ClientThread clientThread;
@Provides @Provides
PlayerIndicatorsConfig provideConfig(ConfigManager configManager) PlayerIndicatorsConfig provideConfig(ConfigManager configManager)
{ {
@@ -249,6 +259,44 @@ public class PlayerIndicatorsPlugin extends Plugin
return newTarget; return newTarget;
} }
@Subscribe
public void onScriptPostFired(ScriptPostFired event)
{
if (event.getScriptId() == ScriptID.TRADE_MAIN_INIT)
{
clientThread.invokeLater(() ->
{
Widget tradeTitle = client.getWidget(WidgetInfo.TRADE_WINDOW_HEADER);
String header = tradeTitle.getText();
String playerName = header.substring(TRADING_WITH_TEXT.length());
Player targetPlayer = findPlayer(playerName);
if (targetPlayer == null)
{
return;
}
Decorations playerColor = getDecorations(targetPlayer);
if (playerColor != null)
{
tradeTitle.setText(TRADING_WITH_TEXT + ColorUtil.wrapWithColorTag(playerName, playerColor.color));
}
});
}
}
private Player findPlayer(String name)
{
for (Player player : client.getPlayers())
{
if (player.getName().equals(name))
{
return player;
}
}
return null;
}
@Value @Value
private static class Decorations private static class Decorations
{ {

View File

@@ -144,7 +144,7 @@ public class Raid
} }
else else
{ {
builder.append(" "); builder.append(' ');
} }
} }

View File

@@ -83,7 +83,7 @@ class RunEnergyOverlay extends Overlay
if (config.replaceOrbText()) if (config.replaceOrbText())
{ {
sb.append("Run Energy: ").append(client.getEnergy()).append("%"); sb.append("Run Energy: ").append(client.getEnergy()).append('%');
} }
else else
{ {

View File

@@ -106,7 +106,7 @@ public class RunepouchOverlay extends WidgetItemOverlay
tooltipBuilder tooltipBuilder
.append(amount) .append(amount)
.append(" ") .append(' ')
.append(ColorUtil.wrapWithColorTag(rune.getName(), Color.YELLOW)) .append(ColorUtil.wrapWithColorTag(rune.getName(), Color.YELLOW))
.append("</br>"); .append("</br>");

View File

@@ -855,7 +855,7 @@ public class SlayerPlugin extends Plugin
sb.append(task.getTask()); sb.append(task.getTask());
if (!Strings.isNullOrEmpty(task.getLocation())) if (!Strings.isNullOrEmpty(task.getLocation()))
{ {
sb.append(" (").append(task.getLocation()).append(")"); sb.append(" (").append(task.getLocation()).append(')');
} }
sb.append(": "); sb.append(": ");
if (killed < 0) if (killed < 0)

View File

@@ -82,7 +82,7 @@ public abstract class TabContentPanel extends JPanel
LocalDateTime currentTime = LocalDateTime.now(); LocalDateTime currentTime = LocalDateTime.now();
if (endTime.getDayOfWeek() != currentTime.getDayOfWeek()) if (endTime.getDayOfWeek() != currentTime.getDayOfWeek())
{ {
sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.getDefault())).append(" "); sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.getDefault())).append(' ');
} }
sb.append("at "); sb.append("at ");
sb.append(formatter.format(endTime)); sb.append(formatter.format(endTime));

View File

@@ -187,8 +187,8 @@ public class TimeTrackingPlugin extends Plugin
{ {
if (commandExecuted.getCommand().equals("resetfarmtick")) if (commandExecuted.getCommand().equals("resetfarmtick"))
{ {
configManager.unsetRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET_PRECISION); configManager.unsetRSProfileConfiguration(CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET_PRECISION);
configManager.unsetRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET); configManager.unsetRSProfileConfiguration(CONFIG_GROUP, TimeTrackingConfig.FARM_TICK_OFFSET);
} }
} }

View File

@@ -550,7 +550,7 @@ public class FarmingTracker
// Same RS account but different profile type // Same RS account but different profile type
if (profileType != RuneScapeProfileType.getCurrent(client)) if (profileType != RuneScapeProfileType.getCurrent(client))
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(Text.titleCase(profile.getType())) .append(Text.titleCase(profile.getType()))
.append(") "); .append(") ");
} }
@@ -564,13 +564,13 @@ public class FarmingTracker
//Don't print profile type when logged out if is STANDARD //Don't print profile type when logged out if is STANDARD
if (client.getGameState() == GameState.LOGIN_SCREEN && profileType == RuneScapeProfileType.STANDARD) if (client.getGameState() == GameState.LOGIN_SCREEN && profileType == RuneScapeProfileType.STANDARD)
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(profile.getDisplayName()) .append(profile.getDisplayName())
.append(") "); .append(") ");
} }
else else
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(profile.getDisplayName()) .append(profile.getDisplayName())
.append(" - ") .append(" - ")
.append(Text.titleCase(profile.getType())) .append(Text.titleCase(profile.getType()))
@@ -580,7 +580,7 @@ public class FarmingTracker
// Different RS account but same profile type // Different RS account but same profile type
else else
{ {
stringBuilder.append("(") stringBuilder.append('(')
.append(profile.getDisplayName()) .append(profile.getDisplayName())
.append(") "); .append(") ");
} }
@@ -616,7 +616,7 @@ public class FarmingTracker
stringBuilder.append(patch.getRegion().isDefinite() ? "the " : "") stringBuilder.append(patch.getRegion().isDefinite() ? "the " : "")
.append(patch.getRegion().getName()) .append(patch.getRegion().getName())
.append("."); .append('.');
notifier.notify(stringBuilder.toString()); notifier.notify(stringBuilder.toString());
} }

View File

@@ -100,7 +100,7 @@ public class TwitchIRCClient extends Thread implements AutoCloseable
return; return;
} }
try try // NOPMD: UseTryWithResources
{ {
register(username, password); register(username, password);
join(channel); join(channel);

View File

@@ -105,7 +105,7 @@ public class OverlayUtil
public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset) public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset)
{ {
net.runelite.api.Point imageLocation = Perspective.getCanvasImageLocation(client, localPoint, image, zOffset); Point imageLocation = Perspective.getCanvasImageLocation(client, localPoint, image, zOffset);
if (imageLocation != null) if (imageLocation != null)
{ {
renderImageLocation(graphics, imageLocation, image); renderImageLocation(graphics, imageLocation, image);
@@ -182,7 +182,7 @@ public class OverlayUtil
renderImageLocation(client, graphics, localLocation, image, 0); renderImageLocation(client, graphics, localLocation, image, 0);
} }
public static void renderHoverableArea(Graphics2D graphics, Shape area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor) public static void renderHoverableArea(Graphics2D graphics, Shape area, Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor)
{ {
if (area != null) if (area != null)
{ {

View File

@@ -182,12 +182,12 @@ public class LineComponent implements LayoutableRenderableEntity
if (wordLen + spaceWidth > spaceLeft) if (wordLen + spaceWidth > spaceLeft)
{ {
wrapped.append("\n").append(word); wrapped.append('\n').append(word);
spaceLeft = maxWidth - wordLen; spaceLeft = maxWidth - wordLen;
} }
else else
{ {
wrapped.append(" ").append(word); wrapped.append(' ').append(word);
spaceLeft -= spaceWidth + wordLen; spaceLeft -= spaceWidth + wordLen;
} }
} }

View File

@@ -96,6 +96,7 @@ public class Timer extends InfoBox
public void setDuration(Duration duration) public void setDuration(Duration duration)
{ {
Preconditions.checkArgument(!duration.isNegative(), "negative duration");
this.duration = duration; this.duration = duration;
endTime = startTime.plus(duration); endTime = startTime.plus(duration);
} }

View File

@@ -43,7 +43,7 @@ public class CallableExceptionLogger<V> implements Callable<V>
} }
catch (Throwable ex) catch (Throwable ex)
{ {
log.warn("Uncaught exception in callable {}", callable, ex); log.error("Uncaught exception in callable {}", callable, ex);
throw ex; throw ex;
} }
} }

View File

@@ -42,7 +42,7 @@ public class RunnableExceptionLogger implements Runnable
} }
catch (Throwable ex) catch (Throwable ex)
{ {
log.warn("Uncaught exception in runnable {}", runnable, ex); log.error("Uncaught exception in runnable {}", runnable, ex);
throw ex; throw ex;
} }
} }

View File

@@ -40,11 +40,11 @@ public class WorldUtil
*/ */
public static EnumSet<WorldType> toWorldTypes(final EnumSet<net.runelite.http.api.worlds.WorldType> apiTypes) public static EnumSet<WorldType> toWorldTypes(final EnumSet<net.runelite.http.api.worlds.WorldType> apiTypes)
{ {
final EnumSet<net.runelite.api.WorldType> types = EnumSet.noneOf(net.runelite.api.WorldType.class); final EnumSet<WorldType> types = EnumSet.noneOf(WorldType.class);
for (net.runelite.http.api.worlds.WorldType apiType : apiTypes) for (net.runelite.http.api.worlds.WorldType apiType : apiTypes)
{ {
types.add(net.runelite.api.WorldType.valueOf(apiType.name())); types.add(WorldType.valueOf(apiType.name()));
} }
return types; return types;