From 4f01dabed44c24bd5c41caf1a3663bdaece294f5 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Tue, 7 Sep 2021 17:55:30 -0600 Subject: [PATCH 1/7] rl-api: fluent widget api --- .../java/net/runelite/api/widgets/Widget.java | 93 +++++++++++-------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java index bb4418804b..e7ad087178 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java @@ -76,7 +76,7 @@ public interface Widget /** * Sets the type of content displayed by the widget. */ - void setContentType(int contentType); + Widget setContentType(int contentType); /** * Gets the current click configuration of the widget. @@ -91,7 +91,7 @@ public interface Widget * * @see WidgetConfig */ - void setClickMask(int mask); + Widget setClickMask(int mask); /** * Gets the parent widget, if this widget is a child. @@ -192,7 +192,7 @@ public interface Widget * * @param text the text to display */ - void setText(String text); + Widget setText(String text); /** * Gets the color as an RGB value. @@ -208,7 +208,7 @@ public interface Widget * @param textColor RGB24 color * @see java.awt.Color#getRGB() */ - void setTextColor(int textColor); + Widget setTextColor(int textColor); /** * Gets the transparency of the rectangle @@ -222,7 +222,7 @@ public interface Widget * * @param transparency 0 = fully opaque, 255 = fully transparent */ - void setOpacity(int transparency); + Widget setOpacity(int transparency); /** * Gets the name "op base" of the widget. @@ -241,7 +241,7 @@ public interface Widget * * @param name the new name */ - void setName(String name); + Widget setName(String name); /** * Gets the Model/NPC/Item ID displayed in the widget. @@ -255,7 +255,7 @@ public interface Widget * * @see WidgetModelType */ - void setModelId(int id); + Widget setModelId(int id); /** * Gets the model type of the widget. @@ -270,7 +270,7 @@ public interface Widget * @param type the new model type * @see WidgetModelType */ - void setModelType(int type); + Widget setModelType(int type); /** * Gets the sequence ID used to animate the model in the widget @@ -284,7 +284,7 @@ public interface Widget * * @see net.runelite.api.AnimationID */ - void setAnimationId(int animationId); + Widget setAnimationId(int animationId); /** * Gets the x rotation of the model displayed in the widget. @@ -300,7 +300,7 @@ public interface Widget * * @param modelX the new model x rotation value */ - void setRotationX(int modelX); + Widget setRotationX(int modelX); /** * Gets the y rotation of the model displayed in the widget. @@ -316,7 +316,7 @@ public interface Widget * * @param modelY the new model y rotation value */ - void setRotationY(int modelY); + Widget setRotationY(int modelY); /** * Gets the z rotation of the model displayed in the widget. @@ -332,7 +332,7 @@ public interface Widget * * @param modelZ the new model z rotation value */ - void setRotationZ(int modelZ); + Widget setRotationZ(int modelZ); /** * Gets the amount zoomed in on the model displayed in the widget. @@ -344,7 +344,7 @@ public interface Widget * * @param modelZoom the new model zoom value */ - void setModelZoom(int modelZoom); + Widget setModelZoom(int modelZoom); /** * Gets the sprite ID displayed in the widget. @@ -362,7 +362,7 @@ public interface Widget /** * Sets if sprites are repeated or stretched */ - void setSpriteTiling(boolean tiling); + Widget setSpriteTiling(boolean tiling); /** * Sets the sprite ID displayed in the widget. @@ -370,7 +370,7 @@ public interface Widget * @param spriteId the sprite ID * @see net.runelite.api.SpriteID */ - void setSpriteId(int spriteId); + Widget setSpriteId(int spriteId); /** * Checks whether this widget or any of its parents are hidden. @@ -394,7 +394,7 @@ public interface Widget * * @param hidden new hidden state */ - void setHidden(boolean hidden); + Widget setHidden(boolean hidden); /** * The index of this widget in it's parent's children array @@ -484,7 +484,7 @@ public interface Widget * * @param itemId the item ID */ - void setItemId(int itemId); + Widget setItemId(int itemId); /** * Gets the quantity of the item displayed by the widget. @@ -498,7 +498,7 @@ public interface Widget * * @param quantity the quantity of the item */ - void setItemQuantity(int quantity); + Widget setItemQuantity(int quantity); /** * Checks if the passed canvas points is inside of this widget's @@ -517,7 +517,7 @@ public interface Widget /** * Sets the amount of pixels the widget is scrolled in the X axis */ - void setScrollX(int scrollX); + Widget setScrollX(int scrollX); /** * Gets the amount of pixels the widget is scrolled in the Y axis @@ -527,7 +527,7 @@ public interface Widget /** * sets the amount of pixels the widget is scrolled in the Y axis */ - void setScrollY(int scrollY); + Widget setScrollY(int scrollY); /** * Gets the size of the widget's viewport in the X axis @@ -537,7 +537,7 @@ public interface Widget /** * Sets the size of the widget's viewport in the X axis */ - void setScrollWidth(int width); + Widget setScrollWidth(int width); /** * Gets the size of the widget's viewport in the Y axis @@ -547,7 +547,7 @@ public interface Widget /** * Sets the size of the widget's viewport in the Y axis */ - void setScrollHeight(int height); + Widget setScrollHeight(int height); /** * Gets the X coordinate of this widget before being adjusted by @@ -561,7 +561,7 @@ public interface Widget * * @see #setXPositionMode(int) */ - void setOriginalX(int originalX); + Widget setOriginalX(int originalX); /** * Gets the Y coordinate of this widget before being adjusted by @@ -575,7 +575,10 @@ public interface Widget * * @see #setYPositionMode(int) */ - void setOriginalY(int originalY); + Widget setOriginalY(int originalY); + + Widget setPos(int x, int y); + Widget setPos(int x, int y, int xMode, int yMode); /** * Gets the height coordinate of this widget before being adjusted by @@ -589,7 +592,7 @@ public interface Widget * * @see #setHeightMode(int) */ - void setOriginalHeight(int originalHeight); + Widget setOriginalHeight(int originalHeight); /** * Gets the width coordinate of this widget before being adjusted by @@ -603,7 +606,10 @@ public interface Widget * * @see #setWidthMode(int) */ - void setOriginalWidth(int originalWidth); + Widget setOriginalWidth(int originalWidth); + + Widget setSize(int width, int height); + Widget setSize(int width, int height, int widthMode, int heightMode); /** * Gets the menu options available on the widget as a sparse array. @@ -614,10 +620,17 @@ public interface Widget * Creates a dynamic widget child * * @param index the index of the new widget in the children list or -1 to append to the back - * @param type the type of the widget + * @param type the {@link WidgetType} of the widget */ Widget createChild(int index, int type); + /** + * Creates a dynamic widget child at the end of the children list + * + * @param type the {@link WidgetType} of the widget + */ + Widget createChild(int type); + /** * Removes all of this widget's dynamic children */ @@ -703,7 +716,7 @@ public interface Widget /** * Sets if the widget has any listeners. This should be called whenever a setXListener function is called */ - void setHasListener(boolean hasListener); + Widget setHasListener(boolean hasListener); /** * This is true if the widget is from an if3 interface, or is dynamically created @@ -760,7 +773,7 @@ public interface Widget * * @see net.runelite.api.FontID */ - void setFontId(int id); + Widget setFontId(int id); /** * Returns the border type of item/sprite on the widget @@ -783,7 +796,7 @@ public interface Widget /** * Sets if text should be shadowed */ - void setTextShadowed(boolean shadowed); + Widget setTextShadowed(boolean shadowed); /** * Returns the widget drag dead zone @@ -813,7 +826,7 @@ public interface Widget /** * Sets the widget {@link net.runelite.api.widgets.ItemQuantityMode} */ - void setItemQuantityMode(int itemQuantityMode); + Widget setItemQuantityMode(int itemQuantityMode); /** * Gets the mode that the X position is calculated from the original X position @@ -828,7 +841,7 @@ public interface Widget * * @see WidgetPositionMode */ - void setXPositionMode(int xpm); + Widget setXPositionMode(int xpm); /** * Gets the mode that the Y position is calculated from the original Y position @@ -843,7 +856,7 @@ public interface Widget * * @see WidgetPositionMode */ - void setYPositionMode(int ypm); + Widget setYPositionMode(int ypm); /** * Get the line height for this widget. @@ -857,7 +870,7 @@ public interface Widget * * @param lineHeight */ - void setLineHeight(int lineHeight); + Widget setLineHeight(int lineHeight); /** * Gets the X axis text position mode @@ -871,7 +884,7 @@ public interface Widget * * @see WidgetTextAlignment */ - void setXTextAlignment(int xta); + Widget setXTextAlignment(int xta); /** * Gets the Y axis text position mode @@ -885,7 +898,7 @@ public interface Widget * * @see WidgetTextAlignment */ - void setYTextAlignment(int yta); + Widget setYTextAlignment(int yta); /** * Gets the mode controlling widget width @@ -900,7 +913,7 @@ public interface Widget * * @see WidgetSizeMode */ - void setWidthMode(int widthMode); + Widget setWidthMode(int widthMode); /** * Gets the mode controlling widget width @@ -915,7 +928,7 @@ public interface Widget * * @see WidgetSizeMode */ - void setHeightMode(int heightMode); + Widget setHeightMode(int heightMode); /** * Gets the font that this widget uses @@ -930,7 +943,7 @@ public interface Widget /** * Sets if the rectangle is filled or just stroked */ - void setFilled(boolean filled); + Widget setFilled(boolean filled); /** * Verb for spell targets @@ -1011,7 +1024,7 @@ public interface Widget /** * Container this can be dragged in */ - void setDragParent(Widget dragParent); + Widget setDragParent(Widget dragParent); /** * Gets the script and arguments to be ran when one of the listened for vars changes. From 22d1014bd3af2af5f3945a164833882ecf50eac9 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Mon, 27 Sep 2021 00:36:19 -0600 Subject: [PATCH 2/7] rl-api: add MagicConstant annotations --- runelite-api/pom.xml | 6 ++ .../main/java/net/runelite/api/Client.java | 13 ++-- .../java/net/runelite/api/CollisionData.java | 3 + .../java/net/runelite/api/WidgetNode.java | 4 ++ .../api/events/ClanChannelChanged.java | 3 + .../net/runelite/api/events/WidgetClosed.java | 3 + .../java/net/runelite/api/widgets/Widget.java | 59 +++++++++++++------ .../net/runelite/client/game/ItemManager.java | 3 +- 8 files changed, 69 insertions(+), 25 deletions(-) diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index 5c263c72f3..9e4922f3d7 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -50,6 +50,12 @@ jsr305 provided + + org.jetbrains + annotations + 23.0.0 + provided + junit diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index acdd728a99..e7616e4ea0 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -34,15 +34,18 @@ import javax.annotation.Nullable; import net.runelite.api.annotations.VisibleForDevtools; import net.runelite.api.annotations.VisibleForExternalPlugins; import net.runelite.api.clan.ClanChannel; +import net.runelite.api.clan.ClanID; import net.runelite.api.clan.ClanSettings; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.api.hooks.Callbacks; import net.runelite.api.hooks.DrawCallbacks; import net.runelite.api.vars.AccountType; +import net.runelite.api.widgets.ItemQuantityMode; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetConfig; import net.runelite.api.widgets.WidgetInfo; +import org.intellij.lang.annotations.MagicConstant; /** * Represents the RuneScape client. @@ -392,7 +395,7 @@ public interface Client extends GameEngine * @return the created sprite */ @Nullable - SpritePixels createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale); + SpritePixels createItemSprite(int itemId, int quantity, int border, int shadowColor, @MagicConstant(valuesFromClass = ItemQuantityMode.class) int stackable, boolean noted, int scale); /** * Loads and creates the sprite images of the passed archive and file IDs. @@ -873,7 +876,7 @@ public interface Client extends GameEngine * * @return the widget flags table */ - HashTable getWidgetFlags(); + HashTable getWidgetFlags(); /** * Gets the widget node component table. @@ -1937,7 +1940,7 @@ public interface Client extends GameEngine * @return * @see KeyCode */ - boolean isKeyPressed(int keycode); + boolean isKeyPressed(@MagicConstant(valuesFromClass = KeyCode.class) int keycode); /** * Get the list of message ids for the recently received cross-world messages. The upper 32 bits of the @@ -1989,7 +1992,7 @@ public interface Client extends GameEngine * @see net.runelite.api.clan.ClanID */ @Nullable - ClanChannel getClanChannel(int clanId); + ClanChannel getClanChannel(@MagicConstant(valuesFromClass = ClanID.class) int clanId); /** * Get clan settings by id @@ -1998,7 +2001,7 @@ public interface Client extends GameEngine * @see net.runelite.api.clan.ClanID */ @Nullable - ClanSettings getClanSettings(int clanId); + ClanSettings getClanSettings(@MagicConstant(valuesFromClass = ClanID.class) int clanId); void setUnlockedFps(boolean unlock); void setUnlockedFpsTarget(int fps); diff --git a/runelite-api/src/main/java/net/runelite/api/CollisionData.java b/runelite-api/src/main/java/net/runelite/api/CollisionData.java index e3840bcb62..c64658665c 100644 --- a/runelite-api/src/main/java/net/runelite/api/CollisionData.java +++ b/runelite-api/src/main/java/net/runelite/api/CollisionData.java @@ -24,6 +24,8 @@ */ package net.runelite.api; +import org.intellij.lang.annotations.MagicConstant; + /** * Represents tile collision data for the scene */ @@ -42,5 +44,6 @@ public interface CollisionData * @return all collision flags for the tiles in the scene * @see Constants#SCENE_SIZE */ + @MagicConstant(flagsFromClass = CollisionDataFlag.class) int[][] getFlags(); } \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/WidgetNode.java b/runelite-api/src/main/java/net/runelite/api/WidgetNode.java index 494a33c40f..86ac7df99e 100644 --- a/runelite-api/src/main/java/net/runelite/api/WidgetNode.java +++ b/runelite-api/src/main/java/net/runelite/api/WidgetNode.java @@ -24,6 +24,9 @@ */ package net.runelite.api; +import net.runelite.api.widgets.WidgetModalMode; +import org.intellij.lang.annotations.MagicConstant; + /** * Represents a widget as an iterable node. */ @@ -40,5 +43,6 @@ public interface WidgetNode extends Node /** * @see net.runelite.api.widgets.WidgetModalMode */ + @MagicConstant(valuesFromClass = WidgetModalMode.class) int getModalMode(); } diff --git a/runelite-api/src/main/java/net/runelite/api/events/ClanChannelChanged.java b/runelite-api/src/main/java/net/runelite/api/events/ClanChannelChanged.java index d9e3edbbff..b5943341e9 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/ClanChannelChanged.java +++ b/runelite-api/src/main/java/net/runelite/api/events/ClanChannelChanged.java @@ -27,6 +27,8 @@ package net.runelite.api.events; import javax.annotation.Nullable; import lombok.Value; import net.runelite.api.clan.ClanChannel; +import net.runelite.api.clan.ClanID; +import org.intellij.lang.annotations.MagicConstant; /** * An event fired when the local player joins or leaves a clan channel. @@ -43,6 +45,7 @@ public class ClanChannelChanged * The clan id, or -1 for guest clan * @see net.runelite.api.clan.ClanID */ + @MagicConstant(valuesFromClass = ClanID.class) private int clanId; /** * Whether or not this was the guest clan channel diff --git a/runelite-api/src/main/java/net/runelite/api/events/WidgetClosed.java b/runelite-api/src/main/java/net/runelite/api/events/WidgetClosed.java index 42193b445f..b3123ec743 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/WidgetClosed.java +++ b/runelite-api/src/main/java/net/runelite/api/events/WidgetClosed.java @@ -25,6 +25,8 @@ package net.runelite.api.events; import lombok.Value; +import net.runelite.api.widgets.WidgetModalMode; +import org.intellij.lang.annotations.MagicConstant; /** * Posted when an interface is about to be closed @@ -40,6 +42,7 @@ public class WidgetClosed /** * @see net.runelite.api.widgets.WidgetModalMode */ + @MagicConstant(valuesFromClass = WidgetModalMode.class) private final int modalMode; /** diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java index e7ad087178..b46ea4e4ec 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java @@ -29,6 +29,8 @@ import java.util.Collection; import javax.annotation.Nullable; import net.runelite.api.FontTypeFace; import net.runelite.api.Point; +import org.intellij.lang.annotations.MagicConstant; +import org.jetbrains.annotations.Range; /** * Represents an on-screen UI element that is drawn on the canvas. @@ -59,6 +61,7 @@ public interface Widget * * @see WidgetType */ + @MagicConstant(valuesFromClass = WidgetType.class) int getType(); /** @@ -66,7 +69,7 @@ public interface Widget * * @see WidgetType */ - void setType(int type); + void setType(@MagicConstant(valuesFromClass = WidgetType.class) int type); /** * Gets the type of content displayed by the widget. @@ -81,9 +84,8 @@ public interface Widget /** * Gets the current click configuration of the widget. * @see WidgetConfig - * - * @see WidgetConfig */ + @MagicConstant(flagsFromClass = WidgetConfig.class) int getClickMask(); /** @@ -91,7 +93,7 @@ public interface Widget * * @see WidgetConfig */ - Widget setClickMask(int mask); + Widget setClickMask(@MagicConstant(flagsFromClass = WidgetConfig.class) int mask); /** * Gets the parent widget, if this widget is a child. @@ -246,7 +248,7 @@ public interface Widget /** * Gets the Model/NPC/Item ID displayed in the widget. * - * @see WidgetModelType + * @see #getModelType() */ int getModelId(); @@ -262,6 +264,7 @@ public interface Widget * * @see WidgetModelType */ + @MagicConstant(valuesFromClass = WidgetModelType.class) int getModelType(); /** @@ -270,7 +273,7 @@ public interface Widget * @param type the new model type * @see WidgetModelType */ - Widget setModelType(int type); + Widget setModelType(@MagicConstant(valuesFromClass = WidgetModelType.class) int type); /** * Gets the sequence ID used to animate the model in the widget @@ -290,6 +293,7 @@ public interface Widget * Gets the x rotation of the model displayed in the widget. * 0 = no rotation, 2047 = full rotation */ + @Range(from = 0, to = 2047) int getRotationX(); /** @@ -300,12 +304,13 @@ public interface Widget * * @param modelX the new model x rotation value */ - Widget setRotationX(int modelX); + Widget setRotationX(@Range(from = 0, to = 2047) int modelX); /** * Gets the y rotation of the model displayed in the widget. * 0 = no rotation, 2047 = full rotation */ + @Range(from = 0, to = 2047) int getRotationY(); /** @@ -316,12 +321,13 @@ public interface Widget * * @param modelY the new model y rotation value */ - Widget setRotationY(int modelY); + Widget setRotationY(@Range(from = 0, to = 2047) int modelY); /** * Gets the z rotation of the model displayed in the widget. * 0 = no rotation, 2047 = full rotation */ + @Range(from = 0, to = 2047) int getRotationZ(); /** @@ -332,7 +338,7 @@ public interface Widget * * @param modelZ the new model z rotation value */ - Widget setRotationZ(int modelZ); + Widget setRotationZ(@Range(from = 0, to = 2047) int modelZ); /** * Gets the amount zoomed in on the model displayed in the widget. @@ -577,8 +583,13 @@ public interface Widget */ Widget setOriginalY(int originalY); + /** + * Sets the X/Y coordinates + */ Widget setPos(int x, int y); - Widget setPos(int x, int y, int xMode, int yMode); + Widget setPos(int x, int y, + @MagicConstant(valuesFromClass = WidgetPositionMode.class) int xMode, + @MagicConstant(valuesFromClass = WidgetPositionMode.class) int yMode); /** * Gets the height coordinate of this widget before being adjusted by @@ -609,7 +620,9 @@ public interface Widget Widget setOriginalWidth(int originalWidth); Widget setSize(int width, int height); - Widget setSize(int width, int height, int widthMode, int heightMode); + Widget setSize(int width, int height, + @MagicConstant(valuesFromClass = WidgetSizeMode.class) int widthMode, + @MagicConstant(valuesFromClass = WidgetSizeMode.class) int heightMode); /** * Gets the menu options available on the widget as a sparse array. @@ -622,14 +635,14 @@ public interface Widget * @param index the index of the new widget in the children list or -1 to append to the back * @param type the {@link WidgetType} of the widget */ - Widget createChild(int index, int type); + Widget createChild(int index, @MagicConstant(valuesFromClass = WidgetType.class) int type); /** * Creates a dynamic widget child at the end of the children list * * @param type the {@link WidgetType} of the widget */ - Widget createChild(int type); + Widget createChild(@MagicConstant(valuesFromClass = WidgetType.class) int type); /** * Removes all of this widget's dynamic children @@ -821,11 +834,13 @@ public interface Widget /** * Returns widget {@link net.runelite.api.widgets.ItemQuantityMode}. */ + @MagicConstant(valuesFromClass = ItemQuantityMode.class) int getItemQuantityMode(); /** * Sets the widget {@link net.runelite.api.widgets.ItemQuantityMode} */ + @MagicConstant(valuesFromClass = ItemQuantityMode.class) Widget setItemQuantityMode(int itemQuantityMode); /** @@ -833,6 +848,7 @@ public interface Widget * * @see WidgetPositionMode */ + @MagicConstant(valuesFromClass = WidgetPositionMode.class) int getXPositionMode(); /** @@ -841,13 +857,14 @@ public interface Widget * * @see WidgetPositionMode */ - Widget setXPositionMode(int xpm); + Widget setXPositionMode(@MagicConstant(valuesFromClass = WidgetPositionMode.class) int xpm); /** * Gets the mode that the Y position is calculated from the original Y position * * @see WidgetPositionMode */ + @MagicConstant(valuesFromClass = WidgetPositionMode.class) int getYPositionMode(); /** @@ -856,7 +873,7 @@ public interface Widget * * @see WidgetPositionMode */ - Widget setYPositionMode(int ypm); + Widget setYPositionMode(@MagicConstant(valuesFromClass = WidgetPositionMode.class) int ypm); /** * Get the line height for this widget. @@ -877,6 +894,7 @@ public interface Widget * * @see WidgetTextAlignment */ + @MagicConstant(valuesFromClass = WidgetTextAlignment.class) int getXTextAlignment(); /** @@ -884,13 +902,14 @@ public interface Widget * * @see WidgetTextAlignment */ - Widget setXTextAlignment(int xta); + Widget setXTextAlignment(@MagicConstant(valuesFromClass = WidgetTextAlignment.class) int xta); /** * Gets the Y axis text position mode * * @see WidgetTextAlignment */ + @MagicConstant(valuesFromClass = WidgetTextAlignment.class) int getYTextAlignment(); /** @@ -898,13 +917,14 @@ public interface Widget * * @see WidgetTextAlignment */ - Widget setYTextAlignment(int yta); + Widget setYTextAlignment(@MagicConstant(valuesFromClass = WidgetTextAlignment.class) int yta); /** * Gets the mode controlling widget width * * @see WidgetSizeMode */ + @MagicConstant(valuesFromClass = WidgetSizeMode.class) int getWidthMode(); /** @@ -913,13 +933,14 @@ public interface Widget * * @see WidgetSizeMode */ - Widget setWidthMode(int widthMode); + Widget setWidthMode(@MagicConstant(valuesFromClass = WidgetSizeMode.class) int widthMode); /** * Gets the mode controlling widget width * * @see WidgetSizeMode */ + @MagicConstant(valuesFromClass = WidgetSizeMode.class) int getHeightMode(); /** @@ -928,7 +949,7 @@ public interface Widget * * @see WidgetSizeMode */ - Widget setHeightMode(int heightMode); + Widget setHeightMode(@MagicConstant(valuesFromClass = WidgetSizeMode.class) int heightMode); /** * Gets the font that this widget uses diff --git a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java index b02b332ef2..e7af66d994 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java @@ -52,6 +52,7 @@ import net.runelite.api.GameState; import net.runelite.api.ItemComposition; import static net.runelite.api.ItemID.*; import net.runelite.api.SpritePixels; +import net.runelite.api.widgets.ItemQuantityMode; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.util.AsyncBufferedImage; @@ -389,7 +390,7 @@ public class ItemManager return false; } SpritePixels sprite = client.createItemSprite(itemId, quantity, 1, SpritePixels.DEFAULT_SHADOW_COLOR, - stackable ? 1 : 0, false, CLIENT_DEFAULT_ZOOM); + stackable ? ItemQuantityMode.ALWAYS : ItemQuantityMode.NEVER, false, CLIENT_DEFAULT_ZOOM); if (sprite == null) { return false; From 9966cad9ea37c045cf5c12efba542a0fe6f0bf96 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Thu, 20 Jan 2022 15:00:35 -0700 Subject: [PATCH 3/7] grounditems/Lootbeam: use more faithful colors --- .../runelite/client/plugins/grounditems/Lootbeam.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/Lootbeam.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/Lootbeam.java index 96d7d34409..fa48aa8d47 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/Lootbeam.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/Lootbeam.java @@ -64,13 +64,15 @@ class Lootbeam short hsl = JagexColor.rgbToHSL(l.color.getRGB(), 1.0d); int hue = JagexColor.unpackHue(hsl); - int sat = Math.min(JagexColor.unpackSaturation(hsl) + 1, JagexColor.SATURATION_MAX); + int sat = JagexColor.unpackSaturation(hsl); int lum = JagexColor.unpackLuminance(hsl); + int satDelta = sat > 2 ? 1 : 0; return md.cloneColors() - .recolor((short) 26432, JagexColor.packHSL(hue, sat, Math.min(lum + 12, JagexColor.LUMINANCE_MAX))) - .recolor((short) 26584, JagexColor.packHSL(hue, sat - 1, Math.max(lum - 12, 0))) - .light(75, 1875, ModelData.DEFAULT_X, ModelData.DEFAULT_Y, ModelData.DEFAULT_Z); + .recolor((short) 26432, JagexColor.packHSL(hue, sat - satDelta, lum)) + .recolor((short) 26584, JagexColor.packHSL(hue, sat, Math.min(lum + 24, JagexColor.LUMINANCE_MAX))) + .light(75 + ModelData.DEFAULT_AMBIENT, 1875 + ModelData.DEFAULT_CONTRAST, + ModelData.DEFAULT_X, ModelData.DEFAULT_Y, ModelData.DEFAULT_Z); }, anim(AnimationID.LOOTBEAM_ANIMATION)), ; From 2eba3a886fb1d7c5292f84ea4326e1561fca90b4 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 21 Jan 2022 00:04:39 -0500 Subject: [PATCH 4/7] slayer: fix reanimated abyssals not counting for tasks --- .../client/plugins/slayer/SlayerPlugin.java | 6 ++--- .../runelite/client/plugins/slayer/Task.java | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index f7913a57c5..b535ec643a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -565,10 +565,10 @@ public class SlayerPlugin extends Plugin log.debug("Slayer xp change delta: {}, killed npcs: {}", delta, taggedNpcsDiedPrevTick); final Task task = Task.getTask(taskName); - if (task != null && task.getMinimumKillXp() > 0) + if (task != null && task.getXpMatcher() != null) { - // Only decrement a kill if the xp drop is above the minimum threshold. This is for Tzhaar and Sire tasks. - if (delta >= task.getMinimumKillXp()) + // Only decrement a kill if the xp drop delta passes the matcher. This is for Tzhaar and Sire tasks. + if (task.getXpMatcher().test(delta)) { killed(max(taggedNpcsDiedPrevTick, 1)); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java index f6fb7dc445..37b517c4ec 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java @@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.List; import java.util.Map; +import java.util.function.IntPredicate; import javax.annotation.Nullable; import lombok.Getter; import net.runelite.api.ItemID; @@ -42,9 +43,10 @@ enum Task // Abyssal demon - 150 xp // Greater abyssal demon - 4200 xp // Abyssal sire - 450 xp - // Use 51 for minimum xp to avoid a kill triggering from killing the sire vents - ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON, 51), - ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN, 51), + // Reanimated abyssal - 31 xp + // Ignore 50xp drops to avoid recording a kill from sire vents + ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON, (xp) -> xp != 50), + ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN, (xp) -> xp != 50), ADAMANT_DRAGONS("Adamant dragons", ItemID.ADAMANT_DRAGON_MASK), ALCHEMICAL_HYDRA("Alchemical Hydra", ItemID.IKKLE_HYDRA), ANKOU("Ankou", ItemID.ANKOU_MASK), @@ -114,7 +116,7 @@ enum Task ICE_WARRIORS("Ice warriors", ItemID.MITHRIL_FULL_HELM_T, "Icelord"), INFERNAL_MAGES("Infernal mages", ItemID.INFERNAL_MAGE, "Malevolent mage"), IRON_DRAGONS("Iron dragons", ItemID.IRON_DRAGON_MASK), - JAD("TzTok-Jad", ItemID.TZREKJAD, 25250), + JAD("TzTok-Jad", ItemID.TZREKJAD, (xp) -> xp == 25250), JELLIES("Jellies", ItemID.JELLY, "Jelly"), JUNGLE_HORROR("Jungle horrors", ItemID.ENSOULED_HORROR_HEAD), KALPHITE("Kalphite", ItemID.KALPHITE_SOLDIER), @@ -183,7 +185,7 @@ enum Task WYRMS("Wyrms", ItemID.WYRM), ZILYANA("Commander Zilyana", ItemID.PET_ZILYANA), ZOMBIES("Zombies", ItemID.ZOMBIE_HEAD, "Undead"), - ZUK("TzKal-Zuk", ItemID.TZREKZUK, 101890), + ZUK("TzKal-Zuk", ItemID.TZREKZUK, (xp) -> xp == 101890), ZULRAH("Zulrah", ItemID.PET_SNAKELING); // @@ -242,7 +244,8 @@ enum Task private final String[] targetNames; private final int weaknessThreshold; private final int weaknessItem; - private final int minimumKillXp; + @Nullable + private final IntPredicate xpMatcher; static { @@ -264,7 +267,7 @@ enum Task this.weaknessThreshold = -1; this.weaknessItem = -1; this.targetNames = targetNames; - this.minimumKillXp = 0; + this.xpMatcher = null; } Task(String name, int itemSpriteId, int weaknessThreshold, int weaknessItem, String... targetNames) @@ -275,10 +278,10 @@ enum Task this.weaknessThreshold = weaknessThreshold; this.weaknessItem = weaknessItem; this.targetNames = targetNames; - this.minimumKillXp = 0; + this.xpMatcher = null; } - Task(String name, int itemSpriteId, int minimumKillXp) + Task(String name, int itemSpriteId, IntPredicate xpMatcher) { Preconditions.checkArgument(itemSpriteId >= 0); this.name = name; @@ -286,7 +289,7 @@ enum Task this.weaknessThreshold = -1; this.weaknessItem = -1; this.targetNames = new String[0]; - this.minimumKillXp = minimumKillXp; + this.xpMatcher = xpMatcher; } @Nullable From 82b28d15fcb82fc928f0202493d082ccad91c7c1 Mon Sep 17 00:00:00 2001 From: Thource Date: Sun, 23 Jan 2022 22:23:19 +0000 Subject: [PATCH 5/7] Remove daily sand check for UIM accounts --- .../client/plugins/dailytaskindicators/DailyTasksPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java index 8e1757b26b..aee48ee463 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/dailytaskindicators/DailyTasksPlugin.java @@ -210,7 +210,8 @@ public class DailyTasksPlugin extends Plugin private void checkSand(boolean dailyReset) { - if (client.getVar(Varbits.QUEST_THE_HAND_IN_THE_SAND) >= SAND_QUEST_COMPLETE + if (client.getAccountType() != AccountType.ULTIMATE_IRONMAN + && client.getVar(Varbits.QUEST_THE_HAND_IN_THE_SAND) >= SAND_QUEST_COMPLETE && (client.getVar(Varbits.DAILY_SAND_COLLECTED) == 0 || dailyReset)) { From aa73a9eabccc9bdc73f5d599a8a9ba1d0c01a815 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 17 Jan 2022 21:53:53 -0600 Subject: [PATCH 6/7] npcunaggroarea: add option to hide when out of combat --- .../plugins/npcunaggroarea/NpcAggroAreaConfig.java | 11 +++++++++++ .../plugins/npcunaggroarea/NpcAggroAreaOverlay.java | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java index 6fbdbb7e08..1532d075c8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java @@ -117,4 +117,15 @@ public interface NpcAggroAreaConfig extends Config { return false; } + + @ConfigItem( + keyName = "hideIfOutOfCombat", + name = "Hide when out of combat", + description = "Hides unaggressive area lines when out of combat.", + position = 8 + ) + default boolean hideIfOutOfCombat() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java index 2e77daa25e..5aad9ce8c6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java @@ -34,6 +34,7 @@ import java.time.Instant; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.Perspective; +import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.api.coords.LocalPoint; import net.runelite.api.geometry.Geometry; @@ -70,6 +71,12 @@ class NpcAggroAreaOverlay extends Overlay return null; } + final Player localPlayer = client.getLocalPlayer(); + if (localPlayer.getHealthScale() == -1 && config.hideIfOutOfCombat()) + { + return null; + } + GeneralPath lines = plugin.getLinesToDisplay()[client.getPlane()]; if (lines == null) { From d44b7f3d0057537b7d14470f4dd44a3953f9ef62 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Wed, 19 Jan 2022 17:49:31 +0000 Subject: [PATCH 7/7] timers: add shattered relics home teleport --- .../src/main/java/net/runelite/api/AnimationID.java | 6 ++++++ .../src/main/java/net/runelite/api/widgets/WidgetID.java | 1 + .../src/main/java/net/runelite/api/widgets/WidgetInfo.java | 1 + .../net/runelite/client/plugins/timers/TeleportWidget.java | 3 ++- .../net/runelite/client/plugins/timers/TimersPlugin.java | 3 ++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/AnimationID.java b/runelite-api/src/main/java/net/runelite/api/AnimationID.java index 59c61ab497..ab4928ccb6 100644 --- a/runelite-api/src/main/java/net/runelite/api/AnimationID.java +++ b/runelite-api/src/main/java/net/runelite/api/AnimationID.java @@ -204,6 +204,12 @@ public final class AnimationID public static final int LEAGUE_HOME_TELEPORT_4 = 8803; public static final int LEAGUE_HOME_TELEPORT_5 = 8805; public static final int LEAGUE_HOME_TELEPORT_6 = 8807; + public static final int SHATTERED_LEAGUE_HOME_TELEPORT_1 = 9209; + public static final int SHATTERED_LEAGUE_HOME_TELEPORT_2 = 9210; + public static final int SHATTERED_LEAGUE_HOME_TELEPORT_3 = 9211; + public static final int SHATTERED_LEAGUE_HOME_TELEPORT_4 = 9212; + public static final int SHATTERED_LEAGUE_HOME_TELEPORT_5 = 9213; + public static final int SHATTERED_LEAGUE_HOME_TELEPORT_6 = 9214; public static final int RAID_LIGHT_ANIMATION = 3101; public static final int LOOTBEAM_ANIMATION = 9260; diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index 74ebdc5ca5..85cd6e8e48 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -761,6 +761,7 @@ public final class WidgetID { static final int LUMBRIDGE_HOME_TELEPORT = 6; static final int KOUREND_HOME_TELEPORT = 4; + static final int CATHERBY_HOME_TELEPORT = 5; } static class AncientSpellBook diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 83b0f2d6a0..baf79a15e7 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -503,6 +503,7 @@ public enum WidgetInfo SPELL_LUNAR_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.LunarSpellBook.LUNAR_HOME_TELEPORT), SPELL_ARCEUUS_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.ArceuusSpellBook.ARCEUUS_HOME_TELEPORT), SPELL_KOUREND_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.StandardSpellBook.KOUREND_HOME_TELEPORT), + SPELL_CATHERBY_HOME_TELEPORT(WidgetID.SPELLBOOK_GROUP_ID, WidgetID.StandardSpellBook.CATHERBY_HOME_TELEPORT), PVP_WILDERNESS_SKULL_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.WILDERNESS_SKULL_CONTAINER), PVP_SKULL_CONTAINER(WidgetID.PVP_GROUP_ID, WidgetID.Pvp.SKULL_CONTAINER), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java index ea3eb66b6a..762d1d19be 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TeleportWidget.java @@ -41,7 +41,8 @@ enum TeleportWidget WidgetInfo.SPELL_EDGEVILLE_HOME_TELEPORT.getId(), WidgetInfo.SPELL_LUNAR_HOME_TELEPORT.getId(), WidgetInfo.SPELL_ARCEUUS_HOME_TELEPORT.getId(), - WidgetInfo.SPELL_KOUREND_HOME_TELEPORT.getId() + WidgetInfo.SPELL_KOUREND_HOME_TELEPORT.getId(), + WidgetInfo.SPELL_CATHERBY_HOME_TELEPORT.getId() ); private static final Collection MINIGAME_TELEPORT_IDS = ImmutableList.of( WidgetInfo.MINIGAME_TELEPORT_BUTTON.getId() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index d5309be51b..6f9efd63c4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -958,7 +958,8 @@ public class TimersPlugin extends Plugin && client.getLocalPlayer().getAnimation() == AnimationID.IDLE && (lastAnimation == AnimationID.BOOK_HOME_TELEPORT_5 || lastAnimation == AnimationID.COW_HOME_TELEPORT_6 - || lastAnimation == AnimationID.LEAGUE_HOME_TELEPORT_6)) + || lastAnimation == AnimationID.LEAGUE_HOME_TELEPORT_6 + || lastAnimation == AnimationID.SHATTERED_LEAGUE_HOME_TELEPORT_6)) { if (lastTeleportClicked == TeleportWidget.HOME_TELEPORT) {