diff --git a/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java b/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java index e234fdfb5f..06ca9bb623 100644 --- a/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java +++ b/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java @@ -25,10 +25,13 @@ package net.runelite.http.api.chat; import com.google.gson.JsonParseException; +import com.google.gson.reflect.TypeToken; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Set; import lombok.AllArgsConstructor; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; @@ -362,4 +365,54 @@ public class ChatClient throw new IOException(ex); } } + + public boolean submitPetList(String username, Collection petList) throws IOException + { + HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() + .addPathSegment("chat") + .addPathSegment("pets") + .addQueryParameter("name", username) + .build(); + + Request request = new Request.Builder() + .post(RequestBody.create(RuneLiteAPI.JSON, RuneLiteAPI.GSON.toJson(petList))) + .url(url) + .build(); + + try (Response response = client.newCall(request).execute()) + { + return response.isSuccessful(); + } + } + + public Set getPetList(String username) throws IOException + { + HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() + .addPathSegment("chat") + .addPathSegment("pets") + .addQueryParameter("name", username) + .build(); + + Request request = new Request.Builder() + .url(url) + .build(); + + try (Response response = client.newCall(request).execute()) + { + if (!response.isSuccessful()) + { + throw new IOException("Unable to look up pet list!"); + } + + InputStream in = response.body().byteStream(); + // CHECKSTYLE:OFF + return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), + new TypeToken>(){}.getType()); + // CHECKSTYLE:ON + } + catch (JsonParseException ex) + { + throw new IOException(ex); + } + } } 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 122a66c047..fc8303ac04 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,7 @@ 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 RAID_LIGHT_ANIMATION = 3101; public static final int CONSTRUCTION = 3676; public static final int CONSTRUCTION_IMCANDO = 8912; 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 0800d2f5f4..9cf9b9c310 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1078,6 +1078,35 @@ public interface Client extends GameEngine */ List getGraphicsObjects(); + /** + * Creates a RuneLiteObject, which is a modified {@link GraphicsObject} + */ + RuneLiteObject createRuneLiteObject(); + + /** + * Loads a model from the cache + * + * @param id the ID of the model + */ + Model loadModel(int id); + + /** + * Loads a model from the cache and also recolors it + * + * @param id the ID of the model + * @param colorToFind array of hsl color values to find in the model to replace + * @param colorToReplace array of hsl color values to replace in the model + */ + Model loadModel(int id, short[] colorToFind, short[] colorToReplace); + + /** + * Loads an animation from the cache + * + * @param id the ID of the animation. Any int is allowed, but implementations in the client + * should be defined in {@link AnimationID} + */ + Sequence loadAnimation(int id); + /** * Gets the music volume * @return volume 0-255 inclusive diff --git a/runelite-api/src/main/java/net/runelite/api/ItemID.java b/runelite-api/src/main/java/net/runelite/api/ItemID.java index 3898ac23ef..d8173d7769 100644 --- a/runelite-api/src/main/java/net/runelite/api/ItemID.java +++ b/runelite-api/src/main/java/net/runelite/api/ItemID.java @@ -11988,5 +11988,39 @@ public final class ItemID public static final int BOW_OF_FAERDHINEN_C_25892 = 25892; public static final int BOW_OF_FAERDHINEN_C_25894 = 25894; public static final int BOW_OF_FAERDHINEN_C_25896 = 25896; + public static final int TZTOK_SLAYER_HELMET = 25898; + public static final int TZTOK_SLAYER_HELMET_I = 25900; + public static final int TZTOK_SLAYER_HELMET_I_25902 = 25902; + public static final int VAMPYRIC_SLAYER_HELMET = 25904; + public static final int VAMPYRIC_SLAYER_HELMET_I = 25906; + public static final int VAMPYRIC_SLAYER_HELMET_I_25908 = 25908; + public static final int TZKAL_SLAYER_HELMET = 25910; + public static final int TZKAL_SLAYER_HELMET_I = 25912; + public static final int TZKAL_SLAYER_HELMET_I_25914 = 25914; + public static final int DRAGON_HUNTER_CROSSBOW_T = 25916; + public static final int DRAGON_HUNTER_CROSSBOW_B = 25918; + public static final int ANTIQUE_LAMP_25920 = 25920; + public static final int ANTIQUE_LAMP_25921 = 25921; + public static final int ANTIQUE_LAMP_25922 = 25922; + public static final int ANTIQUE_LAMP_25923 = 25923; + public static final int ANTIQUE_LAMP_25924 = 25924; + public static final int ANTIQUE_LAMP_25925 = 25925; + public static final int GHOMMALS_HILT_1 = 25926; + public static final int GHOMMALS_HILT_2 = 25928; + public static final int GHOMMALS_HILT_3 = 25930; + public static final int GHOMMALS_HILT_4 = 25932; + public static final int GHOMMALS_HILT_5 = 25934; + public static final int GHOMMALS_HILT_6 = 25936; + public static final int ANIM_OFFHAND = 25938; + public static final int ANIM_OFFHAND_25941 = 25941; + public static final int ANIM_OFFHAND_25944 = 25944; + public static final int ANIM_OFFHAND_25947 = 25947; + public static final int ANIM_OFFHAND_25950 = 25950; + public static final int ANIM_OFFHAND_25953 = 25953; + public static final int COMBAT_ACHIEVEMENTS = 25956; + public static final int CORRUPTED_PADDLEFISH = 25958; + public static final int CORRUPTED_ESCAPE_CRYSTAL = 25959; + public static final int CRYSTAL_PADDLEFISH = 25960; + public static final int ESCAPE_CRYSTAL = 25961; /* This file is automatically generated. Do not edit. */ } \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/JagexColor.java b/runelite-api/src/main/java/net/runelite/api/JagexColor.java new file mode 100644 index 0000000000..618ed002fa --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/JagexColor.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 Abex + * 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. + */ +package net.runelite.api; + +import java.awt.Color; + +public final class JagexColor +{ + public static short packHSL(int hue, int saturation, int luminance) + { + return (short) ((short) (hue & 63) << 10 + | (short) (saturation & 7) << 7 + | (short) (luminance & 127)); + } + + public static short rgbToHSL(int rgb, double brightness) + { + if (rgb == 1) + { + return 0; + } + + brightness = 1.D / brightness; + + double r = (double) (rgb >> 16 & 255) / 256.0D; + double g = (double) (rgb >> 8 & 255) / 256.0D; + double b = (double) (rgb & 255) / 256.0D; + + r = Math.pow(r, brightness); + g = Math.pow(g, brightness); + b = Math.pow(b, brightness); + + float[] hsv = Color.RGBtoHSB((int) (r * 256.D), (int) (g * 256.D), (int) (b * 256.D), null); + double hue = hsv[0]; + double luminance = hsv[2] - ((hsv[2] * hsv[1]) / 2.F); + double saturation = (hsv[2] - luminance) / Math.min(luminance, 1 - luminance); + + return packHSL((int) (Math.ceil(hue * 64.D) % 63.D), + (int) Math.ceil(saturation * 7.D), + (int) Math.ceil(luminance * 127.D)); + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/NpcID.java b/runelite-api/src/main/java/net/runelite/api/NpcID.java index 01479be017..84c1d60367 100644 --- a/runelite-api/src/main/java/net/runelite/api/NpcID.java +++ b/runelite-api/src/main/java/net/runelite/api/NpcID.java @@ -9425,5 +9425,6 @@ public final class NpcID public static final int SRARACHA_11158 = 11158; public static final int SRARACHA_11159 = 11159; public static final int SRARACHA_11160 = 11160; + public static final int DUSTY_ALIV = 11161; /* This file is automatically generated. Do not edit. */ } diff --git a/runelite-api/src/main/java/net/runelite/api/NullItemID.java b/runelite-api/src/main/java/net/runelite/api/NullItemID.java index 3fe975cb45..877196148b 100644 --- a/runelite-api/src/main/java/net/runelite/api/NullItemID.java +++ b/runelite-api/src/main/java/net/runelite/api/NullItemID.java @@ -13699,5 +13699,35 @@ public final class NullItemID public static final int NULL_25893 = 25893; public static final int NULL_25895 = 25895; public static final int NULL_25897 = 25897; + public static final int NULL_25899 = 25899; + public static final int NULL_25901 = 25901; + public static final int NULL_25903 = 25903; + public static final int NULL_25905 = 25905; + public static final int NULL_25907 = 25907; + public static final int NULL_25909 = 25909; + public static final int NULL_25911 = 25911; + public static final int NULL_25913 = 25913; + public static final int NULL_25915 = 25915; + public static final int NULL_25917 = 25917; + public static final int NULL_25919 = 25919; + public static final int NULL_25927 = 25927; + public static final int NULL_25929 = 25929; + public static final int NULL_25931 = 25931; + public static final int NULL_25933 = 25933; + public static final int NULL_25935 = 25935; + public static final int NULL_25937 = 25937; + public static final int NULL_25939 = 25939; + public static final int NULL_25940 = 25940; + public static final int NULL_25942 = 25942; + public static final int NULL_25943 = 25943; + public static final int NULL_25945 = 25945; + public static final int NULL_25946 = 25946; + public static final int NULL_25948 = 25948; + public static final int NULL_25949 = 25949; + public static final int NULL_25951 = 25951; + public static final int NULL_25952 = 25952; + public static final int NULL_25954 = 25954; + public static final int NULL_25955 = 25955; + public static final int NULL_25957 = 25957; /* This file is automatically generated. Do not edit. */ } diff --git a/runelite-api/src/main/java/net/runelite/api/NullObjectID.java b/runelite-api/src/main/java/net/runelite/api/NullObjectID.java index 66971ab20f..5af135a544 100644 --- a/runelite-api/src/main/java/net/runelite/api/NullObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/NullObjectID.java @@ -20726,5 +20726,24 @@ public final class NullObjectID public static final int NULL_42484 = 42484; public static final int NULL_42485 = 42485; public static final int NULL_42486 = 42486; + public static final int NULL_42488 = 42488; + public static final int NULL_42489 = 42489; + public static final int NULL_42490 = 42490; + public static final int NULL_42491 = 42491; + public static final int NULL_42492 = 42492; + public static final int NULL_42493 = 42493; + public static final int NULL_42494 = 42494; + public static final int NULL_42495 = 42495; + public static final int NULL_42496 = 42496; + public static final int NULL_42497 = 42497; + public static final int NULL_42498 = 42498; + public static final int NULL_42499 = 42499; + public static final int NULL_42500 = 42500; + public static final int NULL_42501 = 42501; + public static final int NULL_42502 = 42502; + public static final int NULL_42503 = 42503; + public static final int NULL_42504 = 42504; + public static final int NULL_42505 = 42505; + public static final int NULL_42514 = 42514; /* This file is automatically generated. Do not edit. */ } diff --git a/runelite-api/src/main/java/net/runelite/api/ObjectID.java b/runelite-api/src/main/java/net/runelite/api/ObjectID.java index 6f3377cc0e..fa4f49d8f9 100644 --- a/runelite-api/src/main/java/net/runelite/api/ObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/ObjectID.java @@ -21747,5 +21747,13 @@ public final class ObjectID public static final int YEW_42427 = 42427; public static final int GRANDFATHER_CLOCK_42428 = 42428; public static final int LADDER_42487 = 42487; + public static final int TUNNEL_42506 = 42506; + public static final int TUNNEL_42507 = 42507; + public static final int ROCKS_42508 = 42508; + public static final int ROCKS_42509 = 42509; + public static final int ROCKS_42510 = 42510; + public static final int ROCKS_42511 = 42511; + public static final int ROCKS_42512 = 42512; + public static final int ROCKS_42513 = 42513; /* This file is automatically generated. Do not edit. */ } diff --git a/runelite-api/src/main/java/net/runelite/api/RuneLiteObject.java b/runelite-api/src/main/java/net/runelite/api/RuneLiteObject.java new file mode 100644 index 0000000000..20f2fb001e --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/RuneLiteObject.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021, Trevor + * Copyright (c) 2021 Abex + * 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. + */ +package net.runelite.api; + +import net.runelite.api.coords.LocalPoint; + +/** + * Represents a modified {@link GraphicsObject} + */ +public interface RuneLiteObject extends GraphicsObject +{ + /** + * Sets the model of the RuneLiteObject + */ + void setModel(Model model); + + /** + * Sets the animation of the RuneLiteObject + * If animation is null model will be static + */ + void setAnimation(Sequence animation); + + /** + * Sets whether the animation of the RuneLiteObject should loop when the animation ends. + * If this is false the object will despawn when the animation ends. + * Does nothing if the animation is null. + */ + void setShouldLoop(boolean shouldLoop); + + /** + * Sets the location in the scene for the RuneLiteObject + */ + void setLocation(LocalPoint point, int plane); + + /** + * Sets the state of the RuneLiteObject + * Set to true to spawn the object + * Set to false to despawn the object + */ + void setActive(boolean active); + + /** + * Gets the state of the RuneLiteObject + * + * @return true if the RuneLiteObject is added to the scene + */ + boolean isActive(); +} diff --git a/runelite-api/src/main/java/net/runelite/api/Sequence.java b/runelite-api/src/main/java/net/runelite/api/Sequence.java new file mode 100644 index 0000000000..e7e1c8fcb9 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Sequence.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021, Trevor + * 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. + */ +package net.runelite.api; + +/** + * Represents an animation of a renderable + */ +public interface Sequence +{ +} diff --git a/runelite-api/src/main/java/net/runelite/api/Varbits.java b/runelite-api/src/main/java/net/runelite/api/Varbits.java index 90f91a6b14..bf7ffe4ef4 100644 --- a/runelite-api/src/main/java/net/runelite/api/Varbits.java +++ b/runelite-api/src/main/java/net/runelite/api/Varbits.java @@ -324,7 +324,7 @@ public enum Varbits */ FIRE_PIT_GIANT_MOLE(6532), FIRE_PIT_LUMBRIDGE_SWAMP(6533), - FIRE_PIT_MOS_LE_HARMLESS(6544), + FIRE_PIT_MOS_LE_HARMLESS(6534), /** * Theatre of Blood 1=In Party, 2=Inside/Spectator, 3=Dead Spectating 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 6d3587c526..f0625635c2 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 @@ -153,6 +153,7 @@ public class WidgetID public static final int LMS_GROUP_ID = 333; public static final int LMS_INGAME_GROUP_ID = 328; public static final int ADVENTURE_LOG_ID = 187; + public static final int COLLECTION_LOG_ID = 621; public static final int GENERIC_SCROLL_GROUP_ID = 625; public static final int GAUNTLET_TIMER_GROUP_ID = 637; public static final int HALLOWED_SEPULCHRE_TIMER_GROUP_ID = 668; @@ -958,6 +959,15 @@ public class WidgetID static final int CONTAINER = 0; } + static class CollectionLog + { + static final int CONTAINER = 0; + static final int TABS = 3; + static final int ENTRY = 17; + static final int ENTRY_HEADER = 19; + static final int ENTRY_ITEMS = 36; + } + static class GenericScroll { static final int TEXT = 7; 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 f19545bc34..000290fbf6 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 @@ -482,6 +482,13 @@ public enum WidgetInfo ADVENTURE_LOG(WidgetID.ADVENTURE_LOG_ID, WidgetID.AdventureLog.CONTAINER), + COLLECTION_LOG(WidgetID.COLLECTION_LOG_ID, WidgetID.CollectionLog.CONTAINER), + + COLLECTION_LOG_TABS(WidgetID.COLLECTION_LOG_ID, WidgetID.CollectionLog.TABS), + COLLECTION_LOG_ENTRY(WidgetID.COLLECTION_LOG_ID, WidgetID.CollectionLog.ENTRY), + COLLECTION_LOG_ENTRY_HEADER(WidgetID.COLLECTION_LOG_ID, WidgetID.CollectionLog.ENTRY_HEADER), + COLLECTION_LOG_ENTRY_ITEMS(WidgetID.COLLECTION_LOG_ID, WidgetID.CollectionLog.ENTRY_ITEMS), + GENERIC_SCROLL_TEXT(WidgetID.GENERIC_SCROLL_GROUP_ID, WidgetID.GenericScroll.TEXT), WORLD_SWITCHER_LIST(WidgetID.WORLD_SWITCHER_GROUP_ID, WidgetID.WorldSwitcher.WORLD_LIST), diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml new file mode 100644 index 0000000000..6fea6c3c4c --- /dev/null +++ b/runelite-client/pom.xml @@ -0,0 +1,428 @@ + + + + 4.0.0 + + + net.runelite + runelite-parent + 1.7.18-SNAPSHOT + + + client + RuneLite Client + + + true + true + + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + net.sf.jopt-simple + jopt-simple + 5.0.1 + + + com.google.guava + guava + + + + com.google.code.findbugs + jsr305 + + + com.google.errorprone + error_prone_annotations + + + com.google.j2objc + j2objc-annotations + + + org.codehaus.mojo + animal-sniffer-annotations + + + + + com.google.inject + guice + no_aop + + + com.google.code.gson + gson + + + net.runelite.pushingpixels + substance + 8.0.02 + + + net.runelite.pushingpixels + trident + 1.5.00 + runtime + + + org.projectlombok + lombok + provided + + + org.apache.commons + commons-text + 1.2 + + + net.runelite.jogl + jogl-all + 2.4.0-rc-20200429 + + + net.runelite.jogl + jogl-all + 2.4.0-rc-20200429 + natives-windows-amd64 + runtime + + + net.runelite.jogl + jogl-all + 2.4.0-rc-20200429 + natives-windows-i586 + runtime + + + net.runelite.jogl + jogl-all + 2.4.0-rc-20200429 + natives-linux-amd64 + runtime + + + net.runelite.jogl + jogl-all-natives-macosx + 2.4.0-rc-20210117 + runtime + + + net.runelite.gluegen + gluegen-rt + 2.4.0-rc-20200429 + + + net.runelite.gluegen + gluegen-rt + 2.4.0-rc-20200429 + natives-windows-amd64 + runtime + + + net.runelite.gluegen + gluegen-rt + 2.4.0-rc-20200429 + natives-windows-i586 + runtime + + + net.runelite.gluegen + gluegen-rt + 2.4.0-rc-20200429 + natives-linux-amd64 + runtime + + + net.runelite.gluegen + gluegen-rt-natives-macosx + 2.4.0-rc-20210117 + runtime + + + net.runelite.jocl + jocl + 1.0 + + + net.runelite.jocl + jocl + 1.0 + macos-x64 + runtime + + + net.runelite.jocl + jocl + 1.0 + macos-arm64 + runtime + + + net.runelite + archive-patcher + 1.0 + + + + net.java.dev.jna + jna + 4.5.1 + + + net.java.dev.jna + jna-platform + 4.5.1 + + + com.google.code.findbugs + jsr305 + + + + net.runelite + runelite-api + ${project.version} + + + net.runelite + jshell + ${project.version} + true + + + net.runelite + client-patch + ${project.version} + runtime + + + net.runelite + http-api + ${project.version} + + + net.runelite + discord + 1.4 + + + net.runelite + orange-extensions + 1.0 + provided + + + + junit + junit + 4.12 + test + + + org.hamcrest + hamcrest-library + 1.3 + test + + + org.mockito + mockito-core + 3.1.0 + test + + + com.google.inject.extensions + guice-testlib + test + + + com.google.inject.extensions + guice-grapher + test + + + com.squareup.okhttp3 + mockwebserver + 3.7.0 + test + + + + + + + src/main/resources + + logback.xml + + true + + + src/main/resources + + logback.xml + + false + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + + ttf + png + gif + wav + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + true + shaded + + + + net.runelite.client.RuneLite + + + + + + + + + io.github.zlika + reproducible-build-maven-plugin + + + org.apache.maven.plugins + maven-jarsigner-plugin + 1.4 + + + sign + + sign + + + + + ${jarsigner.skip} + ${jarsigner.keystore} + ${jarsigner.alias} + ${jarsigner.storepass} + ${jarsigner.keypass} + + + + net.runelite + script-assembler-plugin + ${project.version} + + + assemble + + assemble + + + src/main/scripts + ${project.build.outputDirectory}/runelite + + + + build-index + + build-index + + + ${project.build.outputDirectory}/runelite + ${project.build.outputDirectory}/runelite/index + + + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.13.0 + + + net.sourceforge.pmd + pmd-core + 6.29.0 + + + net.sourceforge.pmd + pmd-java + 6.29.0 + + + + true + true + + ${basedir}/pmd-ruleset.xml + + false + true + + + + + check + + + + + + + diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java index a7213a33f1..859aa9f9d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java @@ -179,6 +179,18 @@ public interface ChatCommandsConfig extends Config @ConfigItem( position = 13, + keyName = "pets", + name = "Pets Command", + description = "Configures whether the player pet list command is enabled
!pets
" + + " Note: Update your pet list by looking at the All Pets tab in the Collection Log" + ) + default boolean pets() + { + return true; + } + + @ConfigItem( + position = 20, keyName = "clearSingleWord", name = "Clear Single Word", description = "Enable hot key to clear single word at a time" @@ -189,7 +201,7 @@ public interface ChatCommandsConfig extends Config } @ConfigItem( - position = 14, + position = 21, keyName = "clearEntireChatBox", name = "Clear Chat Box", description = "Enable hotkey to clear entire chat box" diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 9a998e8aca..fe8b03cd26 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -28,14 +28,23 @@ package net.runelite.client.plugins.chatcommands; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableMap; +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; +import com.google.gson.reflect.TypeToken; import com.google.inject.Provides; +import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import javax.inject.Inject; import lombok.Value; import lombok.extern.slf4j.Slf4j; @@ -43,6 +52,7 @@ import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.Experience; import net.runelite.api.IconID; +import net.runelite.api.IndexedSprite; import net.runelite.api.ItemComposition; import net.runelite.api.MessageNode; import net.runelite.api.Player; @@ -57,9 +67,11 @@ import net.runelite.api.events.WidgetLoaded; import net.runelite.api.vars.AccountType; import net.runelite.api.widgets.Widget; import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID; +import static net.runelite.api.widgets.WidgetID.COLLECTION_LOG_ID; import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID; import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.callback.ClientThread; import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageBuilder; @@ -72,6 +84,7 @@ import net.runelite.client.game.ItemManager; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.util.ImageUtil; import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.Text; import net.runelite.http.api.chat.ChatClient; @@ -112,6 +125,7 @@ public class ChatCommandsPlugin extends Plugin "(?:
Overall time: (?[0-9:]+(?:\\.[0-9]+)?)(?: \\(new personal best\\)|. Personal best: (?[0-9:]+(?:\\.[0-9]+)?)))?"); private static final Pattern HS_KC_FLOOR_PATTERN = Pattern.compile("You have completed Floor (\\d) of the Hallowed Sepulchre! Total completions: ([0-9,]+)\\."); private static final Pattern HS_KC_GHC_PATTERN = Pattern.compile("You have opened the Grand Hallowed Coffin ([0-9,]+) times?!"); + private static final Pattern COLLECTION_LOG_ITEM_PATTERN = Pattern.compile("New item added to your collection log: (.*)"); private static final String TOTAL_LEVEL_COMMAND_STRING = "!total"; private static final String PRICE_COMMAND_STRING = "!price"; @@ -128,9 +142,11 @@ public class ChatCommandsPlugin extends Plugin private static final String DUEL_ARENA_COMMAND = "!duels"; private static final String LEAGUE_POINTS_COMMAND = "!lp"; private static final String SOUL_WARS_ZEAL_COMMAND = "!sw"; + private static final String PET_LIST_COMMAND = "!pets"; @VisibleForTesting static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1; + static final int COL_LOG_ENTRY_HEADER_TITLE_INDEX = 0; private static final Map KILLCOUNT_RENAMES = ImmutableMap.of( "Barrows chest", "Barrows Chests" @@ -139,15 +155,20 @@ public class ChatCommandsPlugin extends Plugin private boolean bossLogLoaded; private boolean advLogLoaded; private boolean scrollInterfaceLoaded; + private boolean collectionLogLoaded; private String pohOwner; private HiscoreEndpoint hiscoreEndpoint; // hiscore endpoint for current player private String lastBossKill; private int lastBossTime = -1; private double lastPb = -1; + private int modIconIdx = -1; @Inject private Client client; + @Inject + private ClientThread clientThread; + @Inject private ChatCommandsConfig config; @@ -181,6 +202,9 @@ public class ChatCommandsPlugin extends Plugin @Inject private RuneLiteConfig runeLiteConfig; + @Inject + private Gson gson; + @Override public void startUp() { @@ -201,6 +225,9 @@ public class ChatCommandsPlugin extends Plugin chatCommandManager.registerCommandAsync(GC_COMMAND_STRING, this::gambleCountLookup, this::gambleCountSubmit); chatCommandManager.registerCommandAsync(DUEL_ARENA_COMMAND, this::duelArenaLookup, this::duelArenaSubmit); chatCommandManager.registerCommandAsync(SOUL_WARS_ZEAL_COMMAND, this::soulWarsZealLookup); + chatCommandManager.registerCommandAsync(PET_LIST_COMMAND, this::petListLookup, this::petListSubmit); + + clientThread.invoke(this::loadPetIcons); } @Override @@ -226,6 +253,7 @@ public class ChatCommandsPlugin extends Plugin chatCommandManager.unregisterCommand(GC_COMMAND_STRING); chatCommandManager.unregisterCommand(DUEL_ARENA_COMMAND); chatCommandManager.unregisterCommand(SOUL_WARS_ZEAL_COMMAND); + chatCommandManager.unregisterCommand(PET_LIST_COMMAND); } @Provides @@ -272,6 +300,69 @@ public class ChatCommandsPlugin extends Plugin return personalBest == null ? 0 : personalBest; } + private void loadPetIcons() + { + final IndexedSprite[] modIcons = client.getModIcons(); + if (modIconIdx != -1 || modIcons == null) + { + return; + } + + final Pet[] pets = Pet.values(); + final IndexedSprite[] newModIcons = Arrays.copyOf(modIcons, modIcons.length + pets.length); + modIconIdx = modIcons.length; + + for (int i = 0; i < pets.length; i++) + { + final Pet pet = pets[i]; + + final BufferedImage image = ImageUtil.resizeImage(itemManager.getImage(pet.getIconID()), 18, 16); + final IndexedSprite sprite = ImageUtil.getImageIndexedSprite(image, client); + newModIcons[modIconIdx + i] = sprite; + } + + client.setModIcons(newModIcons); + } + + /** + * Sets the list of owned pets for the local player + * + * @param petList The total list of owned pets for the local player + */ + private void setPetList(List petList) + { + if (petList == null) + { + return; + } + + configManager.setRSProfileConfiguration("chatcommands", "pets", + gson.toJson(petList)); + } + + /** + * Looks up the list of owned pets for the local player + */ + private List getPetList() + { + String petListJson = configManager.getRSProfileConfiguration("chatcommands", "pets", + String.class); + + List petList; + try + { + // CHECKSTYLE:OFF + petList = gson.fromJson(petListJson, new TypeToken>(){}.getType()); + // CHECKSTYLE:ON + } + catch (JsonSyntaxException ex) + { + return Collections.emptyList(); + } + + return petList != null ? petList : Collections.emptyList(); + } + @Subscribe public void onChatMessage(ChatMessage chatMessage) { @@ -431,6 +522,24 @@ public class ChatCommandsPlugin extends Plugin lastBossKill = null; lastBossTime = -1; } + + matcher = COLLECTION_LOG_ITEM_PATTERN.matcher(message); + if (matcher.find()) + { + String item = matcher.group(1); + Pet pet = Pet.findPet(item); + + if (pet != null) + { + List petList = new ArrayList<>(getPetList()); + if (!petList.contains(pet)) + { + log.debug("New pet added: {}", pet); + petList.add(pet); + setPetList(petList); + } + } + } } @VisibleForTesting @@ -490,6 +599,39 @@ public class ChatCommandsPlugin extends Plugin } } + if (collectionLogLoaded && (pohOwner == null || pohOwner.equals(client.getLocalPlayer().getName()))) + { + collectionLogLoaded = false; + + Widget collectionLogEntryHeader = client.getWidget(WidgetInfo.COLLECTION_LOG_ENTRY_HEADER); + if (collectionLogEntryHeader != null && collectionLogEntryHeader.getChildren() != null) + { + Widget entryTitle = collectionLogEntryHeader.getChild(COL_LOG_ENTRY_HEADER_TITLE_INDEX); + // Make sure that the player is looking in the All Pets tab of the collection log + if (entryTitle.getText().equals("All Pets")) + { + Widget collectionLogEntryItems = client.getWidget(WidgetInfo.COLLECTION_LOG_ENTRY_ITEMS); + if (collectionLogEntryItems != null && collectionLogEntryItems.getChildren() != null) + { + List petList = new ArrayList<>(); + for (Widget child : collectionLogEntryItems.getChildren()) + { + if (child.getOpacity() == 0) + { + Pet pet = Pet.findPet(Text.removeTags(child.getName())); + if (pet != null) + { + petList.add(pet); + } + } + } + + setPetList(petList); + } + } + } + } + if (bossLogLoaded && (pohOwner == null || pohOwner.equals(client.getLocalPlayer().getName()))) { bossLogLoaded = false; @@ -566,6 +708,9 @@ public class ChatCommandsPlugin extends Plugin case ADVENTURE_LOG_ID: advLogLoaded = true; break; + case COLLECTION_LOG_ID: + collectionLogLoaded = true; + break; case KILL_LOGS_GROUP_ID: bossLogLoaded = true; break; @@ -583,6 +728,10 @@ public class ChatCommandsPlugin extends Plugin case LOADING: case HOPPING: pohOwner = null; + break; + case LOGGED_IN: + loadPetIcons(); + break; } } @@ -999,6 +1148,103 @@ public class ChatCommandsPlugin extends Plugin return true; } + /** + * Looks up the pet list for the player who triggered !pets + * + * @param chatMessage The chat message containing the command. + * @param message The chat message in string format + *

+ */ + private void petListLookup(ChatMessage chatMessage, String message) + { + if (!config.pets()) + { + return; + } + + ChatMessageType type = chatMessage.getType(); + + final String player; + if (type.equals(ChatMessageType.PRIVATECHATOUT)) + { + player = client.getLocalPlayer().getName(); + } + else + { + player = Text.sanitize(chatMessage.getName()); + } + + Set playerPetList; + try + { + playerPetList = chatClient.getPetList(player); + } + catch (IOException ex) + { + log.debug("unable to lookup pet list", ex); + + if (player.equals(client.getLocalPlayer().getName())) + { + String response = "Open the 'All Pets' tab in the Collection Log to update your pet list"; + log.debug("Setting response {}", response); + final MessageNode messageNode = chatMessage.getMessageNode(); + messageNode.setValue(response); + client.refreshChat(); + } + return; + } + + ChatMessageBuilder responseBuilder = new ChatMessageBuilder().append("Pets: ") + .append("(" + playerPetList.size() + ")"); + + // Append pets that the player owns + Pet[] pets = Pet.values(); + for (Pet pet : pets) + { + if (playerPetList.contains(pet.getIconID())) + { + responseBuilder.append(" ").img(modIconIdx + pet.ordinal()); + } + } + + String response = responseBuilder.build(); + + log.debug("Setting response {}", response); + final MessageNode messageNode = chatMessage.getMessageNode(); + messageNode.setValue(response); + client.refreshChat(); + } + + /** + * Submits the pet list for the local player + * + * @param chatInput The chat message containing the command. + * @param value The chat message + */ + private boolean petListSubmit(ChatInput chatInput, String value) + { + final String playerName = client.getLocalPlayer().getName(); + + executor.execute(() -> + { + try + { + List petList = getPetList().stream().map(Pet::getIconID).collect(Collectors.toList()); + chatClient.submitPetList(playerName, petList); + } + catch (Exception ex) + { + log.warn("unable to submit pet list", ex); + } + finally + { + chatInput.resume(); + } + }); + + return true; + } + /** * Looks up the item price and changes the original message to the * response. diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/Pet.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/Pet.java new file mode 100644 index 0000000000..b48a810ec5 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/Pet.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021, Illya Myshakov + * 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. + */ +package net.runelite.client.plugins.chatcommands; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.runelite.api.ItemID; + +@AllArgsConstructor +@Getter +enum Pet +{ + ABYSSAL_ORPHAN("Abyssal orphan", ItemID.ABYSSAL_ORPHAN), + IKKLE_HYDRA("Ikkle hydra", ItemID.IKKLE_HYDRA), + CALLISTO_CUB("Callisto cub", ItemID.CALLISTO_CUB), + HELLPUPPY("Hellpuppy", ItemID.HELLPUPPY), + PET_CHAOS_ELEMENTAL("Pet chaos elemental", ItemID.PET_CHAOS_ELEMENTAL), + PET_ZILYANA("Pet zilyana", ItemID.PET_ZILYANA), + PET_DARK_CORE("Pet dark core", ItemID.PET_DARK_CORE), + PET_DAGANNOTH_PRIME("Pet dagannoth prime", ItemID.PET_DAGANNOTH_PRIME), + PET_DAGANNOTH_SUPREME("Pet dagannoth supreme", ItemID.PET_DAGANNOTH_SUPREME), + PET_DAGANNOTH_REX("Pet dagannoth rex", ItemID.PET_DAGANNOTH_REX), + TZREKJAD("Tzrek-jad", ItemID.TZREKJAD), + PET_GENERAL_GRAARDOR("Pet general graardor", ItemID.PET_GENERAL_GRAARDOR), + BABY_MOLE("Baby mole", ItemID.BABY_MOLE), + NOON("Noon", ItemID.NOON), + JALNIBREK("Jal-nib-rek", ItemID.JALNIBREK), + KALPHITE_PRINCESS("Kalphite princess", ItemID.KALPHITE_PRINCESS), + PRINCE_BLACK_DRAGON("Prince black dragon", ItemID.PRINCE_BLACK_DRAGON), + PET_KRAKEN("Pet kraken", ItemID.PET_KRAKEN), + PET_KREEARRA("Pet kree'arra", ItemID.PET_KREEARRA), + PET_KRIL_TSUTSAROTH("Pet k'ril tsutsaroth", ItemID.PET_KRIL_TSUTSAROTH), + SCORPIAS_OFFSPRING("Scorpia's offspring", ItemID.SCORPIAS_OFFSPRING), + SKOTOS("Skotos", ItemID.SKOTOS), + PET_SMOKE_DEVIL("Pet smoke devil", ItemID.PET_SMOKE_DEVIL), + VENENATIS_SPIDERLING("Venenatis spiderling", ItemID.VENENATIS_SPIDERLING), + VETION_JR("Vet'ion jr.", ItemID.VETION_JR), + VORKI("Vorki", ItemID.VORKI), + PHOENIX("Phoenix", ItemID.PHOENIX), + PET_SNAKELING("Pet snakeling", ItemID.PET_SNAKELING), + OLMLET("Olmlet", ItemID.OLMLET), + LIL_ZIK("Lil' zik", ItemID.LIL_ZIK), + BLOODHOUND("Bloodhound", ItemID.BLOODHOUND), + PET_PENANCE_QUEEN("Pet penance queen", ItemID.PET_PENANCE_QUEEN), + HERON("Heron", ItemID.HERON), + ROCK_GOLEM("Rock golem", ItemID.ROCK_GOLEM), + BEAVER("Beaver", ItemID.BEAVER), + BABY_CHINCHOMPA("Baby chinchompa", ItemID.BABY_CHINCHOMPA), + GIANT_SQUIRREL("Giant squirrel", ItemID.GIANT_SQUIRREL), + TANGLEROOT("Tangleroot", ItemID.TANGLEROOT), + ROCKY("Rocky", ItemID.ROCKY), + RIFT_GUARDIAN("Rift guardian", ItemID.RIFT_GUARDIAN), + HERBI("Herbi", ItemID.HERBI), + CHOMPY_CHICK("Chompy chick", ItemID.CHOMPY_CHICK), + SRARACHA("Sraracha", ItemID.SRARACHA), + SMOLCANO("Smolcano", ItemID.SMOLCANO), + YOUNGLLEF("Youngllef", ItemID.YOUNGLLEF), + LITTLE_NIGHTMARE("Little nightmare", ItemID.LITTLE_NIGHTMARE), + LIL_CREATOR("Lil' creator", ItemID.LIL_CREATOR), + TINY_TEMPOR("Tiny tempor", ItemID.TINY_TEMPOR); + + private final String name; + private final Integer iconID; + + static Pet findPet(String petName) + { + for (Pet pet : values()) + { + if (pet.name.equals(petName)) + { + return pet; + } + } + return null; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java index 8cc0c6e128..6b9cf11999 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java @@ -207,8 +207,8 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(2484, 4016, 0), new CoordinateClueInfo("Northeast corner of the Island of Stone.", ARMADYLEAN_OR_BANDOSIAN_GUARD)) .put(new WorldPoint(2222, 3331, 0), new CoordinateClueInfo("Prifddinas, west of the Tower of Voices", ARMADYLEAN_OR_BANDOSIAN_GUARD)) .put(new WorldPoint(3560, 3987, 0), new CoordinateClueInfo("Lithkren. Digsite pendant teleport if unlocked, otherwise take rowboat from west of Mushroom Meadow Mushtree.", ARMADYLEAN_OR_BANDOSIAN_GUARD)) - .put(new WorldPoint(2318, 2954, 0), new CoordinateClueInfo("North-east corner of the Isle of Souls.", ARMADYLEAN_OR_BANDOSIAN_GUARD)) - .put(new WorldPoint(2094, 2889, 0), new CoordinateClueInfo("West side of the Isle of Souls.", ARMADYLEAN_OR_BANDOSIAN_GUARD)) + .put(new WorldPoint(2318, 2954, 0), new CoordinateClueInfo("North-east corner of the Isle of Souls.", BANDOSIAN_GUARD)) + .put(new WorldPoint(2094, 2889, 0), new CoordinateClueInfo("West side of the Isle of Souls.", ARMADYLEAN_GUARD)) .put(new WorldPoint(1451, 3509, 0), new CoordinateClueInfo("Ruins of Morra.", ARMADYLEAN_OR_BANDOSIAN_GUARD)) // Master .put(new WorldPoint(2178, 3209, 0), new CoordinateClueInfo("South of Iorwerth Camp.", BRASSICAN_MAGE)) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index 2fd4418fe9..e4748262a5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java @@ -327,7 +327,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Elvish onions.", new WorldPoint(3303, 6092, 0), "Dig in the onion patch east of the Prifddinas allotments."), new CrypticClue("Dig by the Giant's Den entrance, looking out over Lake Molch.", new WorldPoint(1418, 3591, 0), "South-east of Lake Molch in Zeah, outside the cave entrance."), new CrypticClue("Search the crates in the fruit store just east of the Hosidius town centre.", CRATES_27533, new WorldPoint(1798, 3612, 0), "Search the crates in the back room of the Hosidius fruit store."), - new CrypticClue("A graceful man of many colours, his crates must be full of many delights.", "Hill Giant", CRATE_42067, new WorldPoint(1506, 3591, 2), "Kill any Hill Giant for a medium key. Then search the crate on the top floor of Osten's clothing shop in Shayzien."), + new CrypticClue("A graceful man of many colours, his crates must be full of many delights.", "Hill Giant", CRATE_42067, new WorldPoint(1506, 3590, 2), "Kill any Hill Giant for a medium key. Then search the crate on the top floor of Osten's clothing shop in Shayzien."), new CrypticClue("Search the basket of apples in an orchard, south of the unknown grave surrounded by white roses.", APPLE_BASKET, new WorldPoint(1718, 3626, 0), "Search the middle apple basket in the apple orchard north of Hosidius."), new CrypticClue("Dig in the lair of red wings, within the temple of the Sun and Moon.", new WorldPoint(1820, 9935, 0), "Forthos Dungeon. In the center of the red dragons.") ); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/Enemy.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/Enemy.java index 1aef9b493d..eef96b5312 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/Enemy.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/Enemy.java @@ -41,8 +41,12 @@ public enum Enemy ZAMORAK_WIZARD("Zamorak Wizard"), //appears for hard clue coordinate steps not in the wilderness SARADOMIN_WIZARD("Saradomin Wizard"), - //appears for elite clue coordinate steps all areas + //appears for elite clue coordinate steps in most areas ARMADYLEAN_OR_BANDOSIAN_GUARD("Armadylean OR Bandosian Guard"), + //appears for elite clue coordinate steps on the west side of the Isle of Souls + ARMADYLEAN_GUARD("Armadylean Guard"), + //appears for elite clue coordinate steps on the east side of the Isle of Souls + BANDOSIAN_GUARD("Bandosian Guard"), //appears for master clue coordinate and hot cold clues when single-way combat BRASSICAN_MAGE("Brassican Mage"), //appears for master clue coordinate and hot cold clues when multi-way combat diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java index 0b926d30e0..f07a5a6bbc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java @@ -29,7 +29,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import lombok.Builder; import lombok.Data; -import lombok.Value; import net.runelite.api.coords.WorldPoint; @Data @@ -66,11 +65,4 @@ class GroundItem { return lootType != LootType.UNKNOWN; } - - @Value - static class GroundItemKey - { - private int itemId; - private WorldPoint location; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index 96f454cd1c..01693334e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -403,4 +403,26 @@ public interface GroundItemsConfig extends Config { return false; } + + @ConfigItem( + keyName = "showLootbeamForHighlighted", + name = "Highlighted item lootbeams", + description = "Configures lootbeams to show for all highlighted items.", + position = 30 + ) + default boolean showLootbeamForHighlighted() + { + return false; + } + + @ConfigItem( + keyName = "showLootbeamTier", + name = "Lootbeam tier", + description = "Configures which price tiers will trigger a lootbeam", + position = 31 + ) + default HighlightTier showLootbeamTier() + { + return HighlightTier.HIGH; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index e939470613..9fb512c688 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -49,6 +49,7 @@ import net.runelite.api.coords.WorldPoint; import static net.runelite.client.plugins.grounditems.GroundItemsPlugin.MAX_QUANTITY; import net.runelite.client.plugins.grounditems.config.DespawnTimerMode; import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.MENU; +import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.NONE; import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; @@ -107,7 +108,8 @@ public class GroundItemsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - final boolean dontShowOverlay = (config.itemHighlightMode() == MENU || plugin.isHideAll()) && !plugin.isHotKeyPressed(); + final boolean dontShowOverlay = (config.itemHighlightMode() == MENU || config.itemHighlightMode() == NONE + || plugin.isHideAll()) && !plugin.isHotKeyPressed(); if (dontShowOverlay && !config.highlightTiles()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index b7a8fc6500..a9e479885e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -28,7 +28,9 @@ package net.runelite.client.plugins.grounditems; import com.google.common.cache.CacheBuilder; import com.google.common.cache.LoadingCache; import com.google.common.collect.EvictingQueue; +import com.google.common.collect.HashBasedTable; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Table; import com.google.inject.Provides; import java.awt.Color; import java.awt.Rectangle; @@ -38,7 +40,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Queue; @@ -71,6 +73,7 @@ import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuOptionClicked; import net.runelite.client.Notifier; +import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; @@ -83,7 +86,7 @@ import net.runelite.client.input.MouseManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.grounditems.config.HighlightTier; -import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.OVERLAY; +import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.BOTH; import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.NAME; @@ -158,6 +161,9 @@ public class GroundItemsPlugin extends Plugin @Inject private Client client; + @Inject + private ClientThread clientThread; + @Inject private ItemManager itemManager; @@ -177,12 +183,13 @@ public class GroundItemsPlugin extends Plugin private ScheduledExecutorService executor; @Getter - private final Map collectedGroundItems = new LinkedHashMap<>(); + private final Table collectedGroundItems = HashBasedTable.create(); private List priceChecks = ImmutableList.of(); private LoadingCache highlightedItems; private LoadingCache hiddenItems; private final Queue droppedItemQueue = EvictingQueue.create(16); // recently dropped items private int lastUsedItem; + private final Map lootbeams = new HashMap<>(); @Provides GroundItemsConfig provideConfig(ConfigManager configManager) @@ -213,6 +220,7 @@ public class GroundItemsPlugin extends Plugin hiddenItemList = null; highlightedItemsList = null; collectedGroundItems.clear(); + clientThread.invokeLater(this::removeAllLootbeams); } @Subscribe @@ -230,6 +238,7 @@ public class GroundItemsPlugin extends Plugin if (event.getGameState() == GameState.LOADING) { collectedGroundItems.clear(); + lootbeams.clear(); } } @@ -240,19 +249,23 @@ public class GroundItemsPlugin extends Plugin Tile tile = itemSpawned.getTile(); GroundItem groundItem = buildGroundItem(tile, item); - - GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(item.getId(), tile.getWorldLocation()); - GroundItem existing = collectedGroundItems.putIfAbsent(groundItemKey, groundItem); + GroundItem existing = collectedGroundItems.get(tile.getWorldLocation(), item.getId()); if (existing != null) { existing.setQuantity(existing.getQuantity() + groundItem.getQuantity()); // The spawn time remains set at the oldest spawn } + else + { + collectedGroundItems.put(tile.getWorldLocation(), item.getId(), groundItem); + } if (!config.onlyShowLoot()) { notifyHighlightedItem(groundItem); } + + handleLootbeam(tile.getWorldLocation()); } @Subscribe @@ -261,8 +274,7 @@ public class GroundItemsPlugin extends Plugin TileItem item = itemDespawned.getItem(); Tile tile = itemDespawned.getTile(); - GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(item.getId(), tile.getWorldLocation()); - GroundItem groundItem = collectedGroundItems.get(groundItemKey); + GroundItem groundItem = collectedGroundItems.get(tile.getWorldLocation(), item.getId()); if (groundItem == null) { return; @@ -270,7 +282,7 @@ public class GroundItemsPlugin extends Plugin if (groundItem.getQuantity() <= item.getQuantity()) { - collectedGroundItems.remove(groundItemKey); + collectedGroundItems.remove(tile.getWorldLocation(), item.getId()); } else { @@ -280,6 +292,8 @@ public class GroundItemsPlugin extends Plugin // time groundItem.setSpawnTime(null); } + + handleLootbeam(tile.getWorldLocation()); } @Subscribe @@ -291,12 +305,13 @@ public class GroundItemsPlugin extends Plugin int newQuantity = itemQuantityChanged.getNewQuantity(); int diff = newQuantity - oldQuantity; - GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(item.getId(), tile.getWorldLocation()); - GroundItem groundItem = collectedGroundItems.get(groundItemKey); + GroundItem groundItem = collectedGroundItems.get(tile.getWorldLocation(), item.getId()); if (groundItem != null) { groundItem.setQuantity(groundItem.getQuantity() + diff); } + + handleLootbeam(tile.getWorldLocation()); } @Subscribe @@ -366,8 +381,7 @@ public class GroundItemsPlugin extends Plugin for (ItemStack itemStack : items) { WorldPoint location = WorldPoint.fromLocal(client, itemStack.getLocation()); - GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemStack.getId(), location); - GroundItem groundItem = collectedGroundItems.get(groundItemKey); + GroundItem groundItem = collectedGroundItems.get(location, itemStack.getId()); if (groundItem != null) { groundItem.setLootType(lootType); @@ -460,12 +474,14 @@ public class GroundItemsPlugin extends Plugin } priceChecks = priceCheckBuilder.build(); + + clientThread.invokeLater(this::handleLootbeams); } @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (config.itemHighlightMode() != OVERLAY) + if (config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH) { final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == CAST_ON_ITEM; if (!(event.getOption().equals("Take") && event.getType() == THIRD_OPTION) && !telegrabEntry) @@ -481,8 +497,7 @@ public class GroundItemsPlugin extends Plugin MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; final WorldPoint worldPoint = WorldPoint.fromScene(client, sceneX, sceneY, client.getPlane()); - GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemId, worldPoint); - GroundItem groundItem = collectedGroundItems.get(groundItemKey); + GroundItem groundItem = collectedGroundItems.get(worldPoint, itemId); int quantity = groundItem.getQuantity(); final int gePrice = groundItem.getGePrice(); @@ -705,4 +720,103 @@ public class GroundItemsPlugin extends Plugin lastUsedItem = clickedItem.getId(); } } + + private void handleLootbeam(WorldPoint worldPoint) + { + /* + * Return and remove the lootbeam from this location if lootbeam are disabled + * Lootbeam can be at this location if the config was just changed + */ + if (!(config.showLootbeamForHighlighted() || config.showLootbeamTier() != HighlightTier.OFF)) + { + removeLootbeam(worldPoint); + return; + } + + int price = -1; + Collection groundItems = collectedGroundItems.row(worldPoint).values(); + for (GroundItem groundItem : groundItems) + { + if ((config.onlyShowLoot() && !groundItem.isMine())) + { + continue; + } + + /* + * highlighted items have the highest priority so if an item is highlighted at this location + * we can early return + */ + NamedQuantity item = new NamedQuantity(groundItem); + if (config.showLootbeamForHighlighted() + && TRUE.equals(highlightedItems.getUnchecked(item))) + { + addLootbeam(worldPoint, config.highlightedColor()); + return; + } + + // Explicit hide takes priority over implicit highlight + if (TRUE.equals(hiddenItems.getUnchecked(item))) + { + continue; + } + + int itemPrice = getValueByMode(groundItem.getGePrice(), groundItem.getHaPrice()); + price = Math.max(itemPrice, price); + } + + if (config.showLootbeamTier() != HighlightTier.OFF) + { + for (PriceHighlight highlight : priceChecks) + { + if (price > highlight.getPrice() && price > config.showLootbeamTier().getValueFromTier(config)) + { + addLootbeam(worldPoint, highlight.color); + return; + } + } + } + + removeLootbeam(worldPoint); + } + + private void handleLootbeams() + { + for (WorldPoint worldPoint : collectedGroundItems.rowKeySet()) + { + handleLootbeam(worldPoint); + } + } + + private void removeAllLootbeams() + { + for (Lootbeam lootbeam : lootbeams.values()) + { + lootbeam.remove(); + } + + lootbeams.clear(); + } + + private void addLootbeam(WorldPoint worldPoint, Color color) + { + Lootbeam lootbeam = lootbeams.get(worldPoint); + if (lootbeam == null) + { + lootbeam = new Lootbeam(client, worldPoint, color); + lootbeams.put(worldPoint, lootbeam); + } + else + { + lootbeam.setColor(color); + } + } + + private void removeLootbeam(WorldPoint worldPoint) + { + Lootbeam lootbeam = lootbeams.remove(worldPoint); + if (lootbeam != null) + { + lootbeam.remove(); + } + } } 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 new file mode 100644 index 0000000000..1d95a39dc1 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/Lootbeam.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021, Trevor + * 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. + */ +package net.runelite.client.plugins.grounditems; + +import net.runelite.api.AnimationID; +import net.runelite.api.Client; +import net.runelite.api.JagexColor; +import net.runelite.api.RuneLiteObject; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldPoint; +import java.awt.Color; + +class Lootbeam +{ + private static final int RAID_LIGHT_MODEL = 5809; + private static final short RAID_LIGHT_FIND_COLOR = 6371; + + private final RuneLiteObject runeLiteObject; + private final Client client; + private Color color; + + public Lootbeam(Client client, WorldPoint worldPoint, Color color) + { + this.client = client; + runeLiteObject = client.createRuneLiteObject(); + + setColor(color); + runeLiteObject.setAnimation(client.loadAnimation(AnimationID.RAID_LIGHT_ANIMATION)); + runeLiteObject.setShouldLoop(true); + + LocalPoint lp = LocalPoint.fromWorld(client, worldPoint); + runeLiteObject.setLocation(lp, client.getPlane()); + + runeLiteObject.setActive(true); + } + + public void setColor(Color color) + { + if (this.color != null && this.color.equals(color)) + { + return; + } + + this.color = color; + runeLiteObject.setModel(client.loadModel( + RAID_LIGHT_MODEL, + new short[]{RAID_LIGHT_FIND_COLOR}, + new short[]{JagexColor.rgbToHSL(color.getRGB(), 1.0d)} + )); + } + + public void remove() + { + runeLiteObject.setActive(false); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/ItemHighlightMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/ItemHighlightMode.java index 9b873a639e..23d7060ef9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/ItemHighlightMode.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/config/ItemHighlightMode.java @@ -31,6 +31,7 @@ import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public enum ItemHighlightMode { + NONE("None"), OVERLAY("Overlay"), MENU("Right-click menu"), BOTH("Both"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java index 08616dbfdf..36081a3e10 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java @@ -748,7 +748,7 @@ public class MusicPlugin extends Plugin s.update(); s.getChannel().setWindowSlider(s); } - + if (ev.getScriptId() == ScriptID.TOPLEVEL_REDRAW && musicConfig.granularSliders()) { // we have to set the var to our value so toplevel_redraw doesn't try to set @@ -857,11 +857,12 @@ public class MusicPlugin extends Plugin windowSlider.update(); } } - + public void updateVar() { int val = getValue(); - client.getVarps()[this.var.getId()] = val * 100 / this.max; + int varVal = Math.round((float) val / (max / 100.f)); + client.getVarps()[this.var.getId()] = varVal; } public void shutDown() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsConfig.java index 0624edbdc6..cbce85bab4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsConfig.java @@ -27,11 +27,14 @@ package net.runelite.client.plugins.statusbars; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Units; import net.runelite.client.plugins.statusbars.config.BarMode; -@ConfigGroup("statusbars") +@ConfigGroup(StatusBarsConfig.GROUP) public interface StatusBarsConfig extends Config { + String GROUP = "statusbars"; + @ConfigItem( keyName = "enableCounter", name = "Show counters", @@ -81,4 +84,15 @@ public interface StatusBarsConfig extends Config { return BarMode.PRAYER; } + + @ConfigItem( + keyName = "hideAfterCombatDelay", + name = "Hide after combat delay", + description = "Amount of ticks before hiding status bars after no longer in combat. 0 = always show status bars." + ) + @Units(Units.TICKS) + default int hideAfterCombatDelay() + { + return 0; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java index 3710944577..c406bf0d1f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java @@ -80,6 +80,7 @@ class StatusBarsOverlay extends Overlay private static final int MAX_RUN_ENERGY_VALUE = 100; private final Client client; + private final StatusBarsPlugin plugin; private final StatusBarsConfig config; private final ItemStatChangesService itemStatService; private final SpriteManager spriteManager; @@ -94,11 +95,12 @@ class StatusBarsOverlay extends Overlay private final Map barRenderers = new EnumMap<>(BarMode.class); @Inject - private StatusBarsOverlay(Client client, StatusBarsConfig config, SkillIconManager skillIconManager, ItemStatChangesService itemstatservice, SpriteManager spriteManager) + private StatusBarsOverlay(Client client, StatusBarsPlugin plugin, StatusBarsConfig config, SkillIconManager skillIconManager, ItemStatChangesService itemstatservice, SpriteManager spriteManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; + this.plugin = plugin; this.config = config; this.itemStatService = itemstatservice; this.spriteManager = spriteManager; @@ -216,6 +218,11 @@ class StatusBarsOverlay extends Overlay @Override public Dimension render(Graphics2D g) { + if (!plugin.isBarsDisplayed()) + { + return null; + } + Viewport curViewport = null; Widget curWidget = null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java index cb36b42d0d..21e9553b5d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java @@ -26,12 +26,24 @@ package net.runelite.client.plugins.statusbars; import javax.inject.Inject; import com.google.inject.Provides; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.Actor; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.Player; +import net.runelite.api.Varbits; +import net.runelite.api.events.GameTick; +import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.itemstats.ItemStatPlugin; import net.runelite.client.ui.overlay.OverlayManager; +import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( name = "Status Bars", @@ -47,9 +59,24 @@ public class StatusBarsPlugin extends Plugin @Inject private OverlayManager overlayManager; + @Inject + private Client client; + + @Inject + private StatusBarsConfig config; + + @Inject + private ClientThread clientThread; + + @Getter(AccessLevel.PACKAGE) + private boolean barsDisplayed; + + private int lastCombatActionTickCount; + @Override protected void startUp() throws Exception { + clientThread.invokeLater(this::checkStatusBars); overlayManager.add(overlay); } @@ -57,6 +84,7 @@ public class StatusBarsPlugin extends Plugin protected void shutDown() throws Exception { overlayManager.remove(overlay); + barsDisplayed = false; } @Provides @@ -64,4 +92,45 @@ public class StatusBarsPlugin extends Plugin { return configManager.getConfig(StatusBarsConfig.class); } + + @Subscribe + public void onGameTick(GameTick gameTick) + { + checkStatusBars(); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (StatusBarsConfig.GROUP.equals(event.getGroup()) && event.getKey().equals("hideAfterCombatDelay")) + { + clientThread.invokeLater(this::checkStatusBars); + } + } + + private void checkStatusBars() + { + final Player localPlayer = client.getLocalPlayer(); + if (localPlayer == null) + { + return; + } + + final Actor interacting = localPlayer.getInteracting(); + + if (config.hideAfterCombatDelay() == 0) + { + barsDisplayed = true; + } + else if ((interacting instanceof NPC && ArrayUtils.contains(((NPC) interacting).getComposition().getActions(), "Attack")) + || (interacting instanceof Player && client.getVar(Varbits.PVP_SPEC_ORB) == 1)) + { + lastCombatActionTickCount = client.getTickCount(); + barsDisplayed = true; + } + else if (client.getTickCount() - lastCombatActionTickCount >= config.hideAfterCombatDelay()) + { + barsDisplayed = false; + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewTabPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewTabPanel.java index 8ac4c9979e..3fbe3ac505 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewTabPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/OverviewTabPanel.java @@ -31,10 +31,10 @@ import java.time.Instant; import java.util.Map; import java.util.function.Function; import java.util.stream.Stream; -import javax.annotation.Nullable; import net.runelite.api.ItemID; import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.timetracking.clocks.ClockManager; +import net.runelite.client.plugins.timetracking.farming.CropState; import net.runelite.client.plugins.timetracking.farming.FarmingContractManager; import net.runelite.client.plugins.timetracking.farming.FarmingTracker; import net.runelite.client.plugins.timetracking.hunter.BirdHouseTracker; @@ -124,14 +124,13 @@ class OverviewTabPanel extends TabContentPanel } farmingOverviews.forEach((patchType, panel) -> - updateItemPanel(panel, farmingTracker.getSummary(patchType), farmingTracker.getCompletionTime(patchType), null)); + updateItemPanel(panel, farmingTracker.getSummary(patchType), farmingTracker.getCompletionTime(patchType))); - updateItemPanel(birdHouseOverview, birdHouseTracker.getSummary(), birdHouseTracker.getCompletionTime(), null); - updateItemPanel(farmingContractOverview, farmingContractManager.getSummary(), farmingContractManager.getCompletionTime(), - farmingContractManager.getContractName()); + updateItemPanel(birdHouseOverview, birdHouseTracker.getSummary(), birdHouseTracker.getCompletionTime()); + updateContractPanel(); } - private void updateItemPanel(OverviewItemPanel panel, SummaryState summary, long completionTime, @Nullable String farmingContract) + private void updateItemPanel(OverviewItemPanel panel, SummaryState summary, long completionTime) { switch (summary) { @@ -151,10 +150,7 @@ class OverviewTabPanel extends TabContentPanel break; } case EMPTY: - panel.updateStatus(farmingContract == null ? "Empty" : farmingContract, Color.GRAY); - break; - case OCCUPIED: - panel.updateStatus(farmingContract == null ? "" : farmingContract, Color.RED); + panel.updateStatus("Empty", Color.GRAY); break; case UNKNOWN: default: @@ -162,4 +158,45 @@ class OverviewTabPanel extends TabContentPanel break; } } + + private void updateContractPanel() + { + switch (farmingContractManager.getSummary()) + { + case COMPLETED: + case IN_PROGRESS: + switch (farmingContractManager.getContractCropState()) + { + case HARVESTABLE: + case GROWING: + long duration = farmingContractManager.getCompletionTime() - Instant.now().getEpochSecond(); + + if (duration <= 0) + { + farmingContractOverview.updateStatus("Ready", ColorScheme.PROGRESS_COMPLETE_COLOR); + return; + } + + farmingContractOverview.updateStatus("Ready " + getFormattedEstimate(duration, config.timeFormatMode()), Color.GRAY); + return; + case DISEASED: + farmingContractOverview.updateStatus("Diseased", CropState.DISEASED.getColor()); + return; + case DEAD: + farmingContractOverview.updateStatus("Dead", CropState.DEAD.getColor()); + return; + } + // fallthrough + case UNKNOWN: + default: + farmingContractOverview.updateStatus("Unknown", Color.GRAY); + return; + case EMPTY: + farmingContractOverview.updateStatus(farmingContractManager.getContractName(), Color.GRAY); + return; + case OCCUPIED: + farmingContractOverview.updateStatus(farmingContractManager.getContractName(), Color.RED); + return; + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TabContentPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TabContentPanel.java index 88b6362e26..b24f108182 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TabContentPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timetracking/TabContentPanel.java @@ -24,13 +24,16 @@ */ package net.runelite.client.plugins.timetracking; +import java.time.DateTimeException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.TextStyle; import java.time.temporal.ChronoUnit; import java.util.Locale; import javax.swing.JPanel; +import lombok.extern.slf4j.Slf4j; +@Slf4j public abstract class TabContentPanel extends JPanel { private static final DateTimeFormatter DATETIME_FORMATTER_24H = DateTimeFormatter.ofPattern("HH:mm"); @@ -72,17 +75,25 @@ public abstract class TabContentPanel extends JPanel } else { - StringBuilder sb = new StringBuilder(); - LocalDateTime endTime = LocalDateTime.now().plus(remainingSeconds, ChronoUnit.SECONDS); - LocalDateTime currentTime = LocalDateTime.now(); - if (endTime.getDayOfWeek() != currentTime.getDayOfWeek()) + try { - sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.getDefault())).append(" "); - } - sb.append("at "); - sb.append(formatter.format(endTime)); + StringBuilder sb = new StringBuilder(); + LocalDateTime endTime = LocalDateTime.now().plus(remainingSeconds, ChronoUnit.SECONDS); + LocalDateTime currentTime = LocalDateTime.now(); + if (endTime.getDayOfWeek() != currentTime.getDayOfWeek()) + { + sb.append(endTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.getDefault())).append(" "); + } + sb.append("at "); + sb.append(formatter.format(endTime)); - return sb.toString(); + return sb.toString(); + } + catch (DateTimeException e) + { + log.warn("error formatting absolute time: now + {}", remainingSeconds, e); + return "Invalid"; + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/CustomScrollBarUI.java b/runelite-client/src/main/java/net/runelite/client/ui/components/CustomScrollBarUI.java index 128c88197a..d953c615e0 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/CustomScrollBarUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/CustomScrollBarUI.java @@ -90,7 +90,7 @@ public class CustomScrollBarUI extends BasicScrollBarUI { JScrollBar bar = (JScrollBar) c; bar.setUnitIncrement(16); - bar.setPreferredSize(new Dimension(7, 0)); + bar.setPreferredSize(new Dimension(7, 7)); return new CustomScrollBarUI(); } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java index 0c9a52b7e5..2f2beb0c62 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java @@ -130,7 +130,7 @@ public class WorldMapOverlay extends Overlay Area currentClip = null; Point mousePos = client.getMouseCanvasPosition(); - if (!canvasViewArea.contains(mousePos.getX(), mousePos.getY())) + if (!mapViewArea.contains(mousePos.getX(), mousePos.getY())) { mousePos = null; } diff --git a/runelite-client/src/main/resources/item_variations.json b/runelite-client/src/main/resources/item_variations.json index 1c195a11bc..cb3fa513d4 100644 --- a/runelite-client/src/main/resources/item_variations.json +++ b/runelite-client/src/main/resources/item_variations.json @@ -3765,7 +3765,13 @@ 23072, 23082, 25753, - 25820 + 25820, + 25920, + 25921, + 25922, + 25923, + 25924, + 25925 ], "herb tea mix": [ 4464, @@ -7528,7 +7534,16 @@ 25185, 25187, 25189, - 25191 + 25191, + 25898, + 25900, + 25902, + 25904, + 25906, + 25908, + 25910, + 25912, + 25914 ], "slayer ring": [ 11866, @@ -8641,6 +8656,11 @@ 21009, 21206 ], + "dragon hunter crossbow": [ + 21012, + 25916, + 25918 + ], "ancestral hat": [ 21018, 25518 @@ -9884,5 +9904,21 @@ 25892, 25894, 25896 + ], + "ghommals hilt": [ + 25926, + 25928, + 25930, + 25932, + 25934, + 25936 + ], + "anim offhand": [ + 25938, + 25941, + 25944, + 25947, + 25950, + 25953 ] } \ No newline at end of file diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc b/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc index b1909d8559..17d5c6140d 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/roofremoval/overrides.jsonc @@ -552,7 +552,7 @@ "rx2": 50, "ry2": 29, "z1": 0, - "z2": 0 + "z2": 2 }, { "rx1": 13, @@ -724,6 +724,14 @@ } ], "10288": [ // Yanille East + { + "rx1": 27, + "ry1": 12, + "rx2": 33, + "ry2": 19, + "z1": 1, + "z2": 1 + }, { "rx1": 47, "ry1": 19, @@ -2167,5 +2175,243 @@ "z1": 0, "z2": 2 } + ], + "11310": [ // Shilo Village + { + "rx1": 26, + "ry1": 52, + "rx2": 28, + "ry2": 54, + "z1": 0, + "z2": 0 + }, + { + "rx1": 26, + "ry1": 58, + "rx2": 28, + "ry2": 60, + "z1": 0, + "z2": 0 + }, + { + "rx1": 27, + "ry1": 55, + "rx2": 27, + "ry2": 57, + "z1": 0, + "z2": 0 + }, + { + "rx1": 33, + "ry1": 52, + "rx2": 35, + "ry2": 54, + "z1": 0, + "z2": 0 + }, + { + "rx1": 29, + "ry1": 53, + "rx2": 32, + "ry2": 53, + "z1": 0, + "z2": 0 + }, + { + "rx1": 44, + "ry1": 49, + "rx2": 46, + "ry2": 57, + "z1": 0, + "z2": 0 + }, + { + "rx1": 43, + "ry1": 50, + "rx2": 47, + "ry2": 56, + "z1": 0, + "z2": 0 + }, + { + "rx1": 42, + "ry1": 51, + "rx2": 48, + "ry2": 55, + "z1": 0, + "z2": 0 + }, + { + "rx1": 41, + "ry1": 52, + "rx2": 49, + "ry2": 54, + "z1": 0, + "z2": 0 + }, + { + "rx1": 36, + "ry1": 53, + "rx2": 40, + "ry2": 53, + "z1": 0, + "z2": 0 + }, + { + "rx1": 43, + "ry1": 44, + "rx2": 47, + "ry2": 46, + "z1": 0, + "z2": 0 + }, + { + "rx1": 45, + "ry1": 43, + "rx2": 45, + "ry2": 48, + "z1": 0, + "z2": 0 + }, + { + "rx1": 53, + "ry1": 51, + "rx2": 55, + "ry2": 55, + "z1": 0, + "z2": 0 + }, + { + "rx1": 50, + "ry1": 53, + "rx2": 56, + "ry2": 53, + "z1": 0, + "z2": 0 + }, + { + "rx1": 52, + "ry1": 37, + "rx2": 54, + "ry2": 39, + "z1": 0, + "z2": 0 + }, + { + "rx1": 8, + "ry1": 18, + "rx2": 9, + "ry2": 19, + "z1": 0, + "z2": 0 + }, + { + "rx1": 53, + "ry1": 29, + "rx2": 53, + "ry2": 36, + "z1": 0, + "z2": 0 + } + ], + "12340": [ // Draynor Manor + { + "rx1": 30, + "ry1": 24, + "rx2": 43, + "ry2": 24, + "z1": 0, + "z2": 0 + } + ], + "9265": [ // Lletya + { + "rx1": 23, + "ry1": 34, + "rx2": 23, + "ry2": 37, + "z1": 0, + "z2": 0 + } + ], + "15148": [ // Harmony Island + { + "rx1": 30, + "ry1": 24, + "rx2": 40, + "ry2": 32, + "z1": 0, + "z2": 0 + }, + { + "rx1": 41, + "ry1": 18, + "rx2": 48, + "ry2": 36, + "z1": 0, + "z2": 0 + }, + { + "rx1": 41, + "ry1": 37, + "rx2": 45, + "ry2": 38, + "z1": 0, + "z2": 0 + }, + { + "rx1": 34, + "ry1": 57, + "rx2": 38, + "ry2": 57, + "z1": 0, + "z2": 0 + } + ], + "11423": [ // NW Keldagrim + { + "rx1": 60, + "ry1": 11, + "rx2": 63, + "ry2": 36, + "z1": 0, + "z2": 1 + } + ], + "11678": [ // SE Keldagrim + { + "rx1": 49, + "ry1": 46, + "rx2": 49, + "ry2": 51, + "z1": 0, + "z2": 0 + }, + { + "rx1": 50, + "ry1": 56, + "rx2": 51, + "ry2": 63, + "z1": 0, + "z2": 0 + } + ], + "11679": [ // NE Keldagrim + { + "rx1": 50, + "ry1": 0, + "rx2": 51, + "ry2": 1, + "z1": 0, + "z2": 0 + }, + { + "rx1": 0, + "ry1": 11, + "rx2": 3, + "ry2": 36, + "z1": 0, + "z2": 1 + } ] } diff --git a/runelite-client/src/main/scripts/CommandScript.hash b/runelite-client/src/main/scripts/CommandScript.hash index 2aac5e8d08..ff5e4cfbf5 100644 --- a/runelite-client/src/main/scripts/CommandScript.hash +++ b/runelite-client/src/main/scripts/CommandScript.hash @@ -1 +1 @@ -2FE66C1A3B63EEF10142A955C927054613F59A34C4A929C8AC79DBE0F1B06C30 \ No newline at end of file +9D5F23C8B25B79FF2B23F6AE449EDF74645E808B67ECF0E389B626966E86B1BD \ No newline at end of file diff --git a/runelite-client/src/main/scripts/CommandScript.rs2asm b/runelite-client/src/main/scripts/CommandScript.rs2asm index cb21384884..ed0caf568d 100644 --- a/runelite-client/src/main/scripts/CommandScript.rs2asm +++ b/runelite-client/src/main/scripts/CommandScript.rs2asm @@ -273,7 +273,7 @@ LABEL226: iload 6 ; prefix length iload 5 ; chat type sconst "preChatSendpublic" - runelite_callback + runelite_callback istore 5 ; chat type istore 6 ; prefix length get_varc_string 335 ; load input string @@ -565,7 +565,7 @@ LABEL441: if_icmpeq LABEL445 jump LABEL490 LABEL445: - iconst 40697935 + iconst 40697936 iconst 1 cc_find iconst 1 diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/grounditems/GroundItemsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/grounditems/GroundItemsPluginTest.java index 48d6296ca5..92cd6b28bc 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/grounditems/GroundItemsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/grounditems/GroundItemsPluginTest.java @@ -111,6 +111,8 @@ public class GroundItemsPluginTest when(client.getLocalPlayer()).thenReturn(mock(Player.class)); when(config.getHiddenItems()).thenReturn(""); + when(config.showLootbeamForHighlighted()).thenReturn(false); + when(config.showLootbeamTier()).thenReturn(HighlightTier.OFF); } @Test diff --git a/runelite-jshell/src/main/java/net/runelite/jshell/ShellPanel.java b/runelite-jshell/src/main/java/net/runelite/jshell/ShellPanel.java index 1fd17a5711..8a5c07c1d1 100644 --- a/runelite-jshell/src/main/java/net/runelite/jshell/ShellPanel.java +++ b/runelite-jshell/src/main/java/net/runelite/jshell/ShellPanel.java @@ -55,6 +55,7 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; import javax.swing.text.Segment; +import jdk.jshell.DeclarationSnippet; import jdk.jshell.Diag; import jdk.jshell.JShell; import jdk.jshell.Snippet; @@ -185,7 +186,6 @@ public abstract class ShellPanel extends JPanel } console.setFont(codeFont); - console.setFocusable(false); console.setEditable(false); console.setOpaque(false); // this turns off the hover effect for some reason @@ -316,11 +316,13 @@ public abstract class ShellPanel extends JPanel { Snippet snip = ev.snippet(); offsets.put("#" + snip.id(), thisOffset); - if (ev.status() != Snippet.Status.VALID && ev.status() != Snippet.Status.RECOVERABLE_DEFINED) + if (ev.status() != Snippet.Status.VALID) { + boolean handled = false; var diags = shell.diagnostics(snip).collect(Collectors.toList()); for (var diag : diags) { + handled = true; String msg = toStringDiagnostic(src, thisOffset, diag); if (isUserCode) { @@ -332,11 +334,23 @@ public abstract class ShellPanel extends JPanel throw new RuntimeException("prelude error: " + msg); } } - if (diags.isEmpty()) + if (snip instanceof DeclarationSnippet) + { + var unresolved = shell.unresolvedDependencies((DeclarationSnippet) snip).collect(Collectors.toList()); + for (var ident : unresolved) + { + handled = true; + logToConsole("Unresolved symbol: " + ident); + } + } + if (!handled) { logToConsole("bad snippet" + ev.status()); } - break evaluation; + if (ev.status() != Snippet.Status.RECOVERABLE_DEFINED) + { + break evaluation; + } } if (ev.exception() != null) { @@ -419,18 +433,23 @@ public abstract class ShellPanel extends JPanel private void cleanup() { - for (var c : cleanup) - { - try - { - c.run(); - } - catch (Exception e) - { - shellLogger.error("Cleanup threw:", e); - } - } + var todo = new ArrayList<>(cleanup); cleanup.clear(); + + invokeOnClientThread(() -> + { + for (var c : todo) + { + try + { + c.run(); + } + catch (Exception e) + { + shellLogger.error("Cleanup threw:", e); + } + } + }); } protected abstract void invokeOnClientThread(Runnable r);