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 a8d2b786ee..a27caba9b1 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -1255,11 +1255,10 @@ public interface Client extends GameShell * * This method must be ran on the client thread and is not reentrant * - * @param id the script ID - * @param args additional arguments to execute the script with + * @param args the script id, then any additional arguments to execute the script with * @see ScriptID */ - void runScript(int id, Object... args); + void runScript(Object... args); /** * Checks whether or not there is any active hint arrow. diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptArguments.java b/runelite-api/src/main/java/net/runelite/api/ScriptArguments.java new file mode 100644 index 0000000000..c3e89f56a4 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/ScriptArguments.java @@ -0,0 +1,47 @@ +/* + * 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.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.SOURCE) +@Documented +@Target(ElementType.FIELD) +@interface ScriptArguments +{ + /** + * The number of int arguments the script takes + */ + int integer() default 0; + + /** + * The number of string arguments the script takes + */ + int string() default 0; +} diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java index 6ef1089365..dd3acab212 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -34,6 +34,7 @@ public final class ScriptID *
  • int how far down to scroll
  • * */ + @ScriptArguments(integer = 3) public static final int UPDATE_SCROLLBAR = 72; /** @@ -43,11 +44,13 @@ public final class ScriptID *
  • String Message to send
  • * */ + @ScriptArguments(integer = 1, string = 1) public static final int CHATBOX_INPUT = 96; /** * Rebuilds the chatbox */ + @ScriptArguments() public static final int BUILD_CHATBOX = 216; /** @@ -58,6 +61,7 @@ public final class ScriptID *
  • String Player to send private message to
  • * */ + @ScriptArguments(string = 1) public static final int OPEN_PRIVATE_MESSAGE_INTERFACE = 107; /** @@ -66,15 +70,9 @@ public final class ScriptID *
  • String Message Prefix. Only used inside the GE search interfaces * */ + @ScriptArguments(string = 1) public static final int CHAT_TEXT_INPUT_REBUILD = 222; - /** - * Layouts the bank widgets - * - * Takes 13 widget ids of various parts of the bank interface - */ - public static final int BANK_LAYOUT = 277; - /** * Closes the chatbox input * */ - public static final int RESET_CHATBOX_INPUT = 299; + @ScriptArguments(integer = 2) + public static final int MESSAGE_LAYER_CLOSE = 299; /** * Readies the chatbox panel for things like the chatbox input - * Inverse of RESET_CHATBOX_INPUT + * Inverse of MESSAGE_LAYER_CLOSE + * */ - public static final int CLEAR_CHATBOX_PANEL = 677; + @ScriptArguments(integer = 1) + public static final int MESSAGE_LAYER_OPEN = 677; /** * Builds the chatbox input widget */ + @ScriptArguments() public static final int CHAT_PROMPT_INIT = 223; /** @@ -103,6 +107,7 @@ public final class ScriptID *
  • String Item Name
  • * */ + @ScriptArguments(integer = 2, string = 1) public static final int DEATH_KEEP_ITEM_EXAMINE = 1603; /** @@ -116,6 +121,7 @@ public final class ScriptID *

    * Returns a pair of booleans indicating if the stash unit is built and if it is filled */ + @ScriptArguments(integer = 4) public static final int WATSON_STASH_UNIT_CHECK = 1479; /** @@ -128,6 +134,7 @@ public final class ScriptID *

  • int (QuestState) the normalized state of the quest * */ + @ScriptArguments(integer = 1) public static final int QUESTLIST_PROGRESS = 2267; /** @@ -137,6 +144,7 @@ public final class ScriptID *
  • int Number of lines
  • * */ + @ScriptArguments(integer = 2) public static final int DIARY_QUEST_UPDATE_LINECOUNT = 2523; /** @@ -157,6 +165,7 @@ public final class ScriptID *
  • int Reset zoom position
  • * */ + @ScriptArguments(integer = 2) public static final int CAMERA_DO_ZOOM = 42; /** @@ -165,11 +174,13 @@ public final class ScriptID * This is used to eat events when you want a menu action attached to it * because you need an op listener attached to it for it to work */ + @ScriptArguments() public static final int NULL = 10003; /** * Send a private message. */ + @ScriptArguments(string = 2) public static final int PRIVMSG = 10004; /** @@ -180,6 +191,7 @@ public final class ScriptID *
  • int Amount of exp to drop
  • * */ + @ScriptArguments(integer = 2) public static final int XPDROP_DISABLED = 2091; /** diff --git a/runelite-api/src/main/java/net/runelite/api/VarClientInt.java b/runelite-api/src/main/java/net/runelite/api/VarClientInt.java index 55aee587ff..2600b038dd 100644 --- a/runelite-api/src/main/java/net/runelite/api/VarClientInt.java +++ b/runelite-api/src/main/java/net/runelite/api/VarClientInt.java @@ -42,6 +42,10 @@ public enum VarClientInt */ TOOLTIP_VISIBLE(2), + /** + * Current message layer mode + * @see net.runelite.api.vars.InputType + */ INPUT_TYPE(5), MEMBERSHIP_STATUS(103), 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 07f7c4c52d..bb1a3a04ab 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 @@ -623,6 +623,8 @@ public interface Widget */ Object[] getOnLoadListener(); + Object[] getOnInvTransmitListener(); + /** * Returns the archive id of the font used * diff --git a/runelite-client/src/main/java/net/runelite/client/Notifier.java b/runelite-client/src/main/java/net/runelite/client/Notifier.java index 578caaa184..4c2e37c97b 100644 --- a/runelite-client/src/main/java/net/runelite/client/Notifier.java +++ b/runelite-client/src/main/java/net/runelite/client/Notifier.java @@ -72,8 +72,9 @@ public class Notifier private static final int MINIMUM_FLASH_DURATION_MILLIS = 2000; private static final int MINIMUM_FLASH_DURATION_TICKS = MINIMUM_FLASH_DURATION_MILLIS / Constants.CLIENT_TICK_LENGTH; + private static final String appName = RuneLiteProperties.getTitle(); + private final Client client; - private final String appName; private final RuneLiteConfig runeLiteConfig; private final ClientUI clientUI; private final ScheduledExecutorService executorService; @@ -88,12 +89,10 @@ public class Notifier final ClientUI clientUI, final Client client, final RuneLiteConfig runeliteConfig, - final RuneLiteProperties runeLiteProperties, final ScheduledExecutorService executorService, final ChatMessageManager chatMessageManager) { this.client = client; - this.appName = runeLiteProperties.getTitle(); this.clientUI = clientUI; this.runeLiteConfig = runeliteConfig; this.executorService = executorService; diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index 5048173093..117d03bcfb 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -346,10 +346,7 @@ public class RuneLite splashScreen.setProgress(5, 5); // Initialize UI - clientUI.open(this); - - // Close the splash screen - splashScreen.close(); + clientUI.init(this); if (!isOutdated) { @@ -374,6 +371,11 @@ public class RuneLite overlayManager.add(arrowMinimapOverlay.get()); } + // Close the splash screen + splashScreen.close(); + + clientUI.show(); + // Start plugins pluginManager.startCorePlugins(); @@ -398,4 +400,4 @@ public class RuneLite { RuneLite.injector = injector; } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java index 99e3bd50d5..ba6ef10c67 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java @@ -24,16 +24,12 @@ */ package net.runelite.client; +import com.google.inject.Singleton; import java.io.IOException; import java.io.InputStream; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Singleton; -import lombok.extern.slf4j.Slf4j; -import net.runelite.client.config.RuneLitePlusConfig; @Singleton -@Slf4j public class RuneLiteProperties { private static final String RUNELITE_TITLE = "runelite.plus.title"; @@ -47,32 +43,25 @@ public class RuneLiteProperties private static final String WIKI_LINK = "runelite.wiki.link"; private static final String PATREON_LINK = "runelite.patreon.link"; private static final String LAUNCHER_VERSION_PROPERTY = "runelite.launcher.version"; + private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link"; + private static final String BUILDING_LINK = "runelite.wiki.building.link"; + private static final String DNS_CHANGE_LINK = "runelite.dnschange.link"; - private final Properties properties = new Properties(); + private static final Properties properties = new Properties(); - private final RuneLitePlusConfig runeLitePlusConfig; - - @Inject - public RuneLiteProperties(final RuneLitePlusConfig runeLiteConfig) + static { - this.runeLitePlusConfig = runeLiteConfig; - - try (InputStream in = getClass().getResourceAsStream("/runelite.plus.properties")) + try (InputStream in = RuneLiteProperties.class.getResourceAsStream("/runelite.plus.properties")) { properties.load(in); } catch (IOException ex) { - log.warn("unable to load propertries", ex); + throw new RuntimeException(ex); } } - public RuneLiteProperties() - { - runeLitePlusConfig = null; - } - - public String getTitle() + public static String getTitle() { final StringBuilder sb = new StringBuilder(properties.getProperty(RUNELITE_TITLE)); String proxy; @@ -83,48 +72,63 @@ public class RuneLiteProperties return sb.toString(); } - public String getVersion() + public static String getVersion() { return properties.getProperty(RUNELITE_VERSION); } - public String getPlusVersion() + public static String getPlusVersion() { return properties.getProperty(RUNELITE_PLUS_VERSION); } - public String getPlusDate() + public static String getPlusDate() { return properties.getProperty(RUNELITE_PLUS_DATE); } - public String getRunescapeVersion() + public static String getRunescapeVersion() { return properties.getProperty(RUNESCAPE_VERSION); } - public String getDiscordAppId() + public static String getDiscordAppId() { return properties.getProperty(DISCORD_APP_ID); } - public String getDiscordInvite() + public static String getDiscordInvite() { return properties.getProperty(DISCORD_INVITE); } - public String getGithubLink() + public static String getGithubLink() { return properties.getProperty(GITHUB_LINK); } - public String getWikiLink() + public static String getWikiLink() { return properties.getProperty(WIKI_LINK); } - public String getPatreonLink() + public static String getPatreonLink() { return properties.getProperty(PATREON_LINK); } -} + + public static String getTroubleshootingLink() + { + return properties.getProperty(TROUBLESHOOTING_LINK); + } + + public static String getBuildingLink() + { + return properties.getProperty(BUILDING_LINK); + } + + public static String getDNSChangeLink() + { + return properties.getProperty(DNS_CHANGE_LINK); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/discord/DiscordService.java b/runelite-client/src/main/java/net/runelite/client/discord/DiscordService.java index b8abbc518b..a05c8ca74d 100644 --- a/runelite-client/src/main/java/net/runelite/client/discord/DiscordService.java +++ b/runelite-client/src/main/java/net/runelite/client/discord/DiscordService.java @@ -49,7 +49,6 @@ import net.runelite.discord.DiscordUser; public class DiscordService implements AutoCloseable { private final EventBus eventBus; - private final RuneLiteProperties runeLiteProperties; private final ScheduledExecutorService executorService; private final DiscordRPC discordRPC; @@ -62,12 +61,10 @@ public class DiscordService implements AutoCloseable @Inject private DiscordService( final EventBus eventBus, - final RuneLiteProperties runeLiteProperties, final ScheduledExecutorService executorService) { this.eventBus = eventBus; - this.runeLiteProperties = runeLiteProperties; this.executorService = executorService; DiscordRPC discordRPC = null; @@ -106,7 +103,7 @@ public class DiscordService implements AutoCloseable discordEventHandlers.joinGame = this::joinGame; discordEventHandlers.spectateGame = this::spectateGame; discordEventHandlers.joinRequest = this::joinRequest; - discordRPC.Discord_Initialize(runeLiteProperties.getDiscordAppId(), discordEventHandlers, true, null); + discordRPC.Discord_Initialize(RuneLiteProperties.getDiscordAppId(), discordEventHandlers, true, null); executorService.scheduleAtFixedRate(discordRPC::Discord_RunCallbacks, 0, 2, TimeUnit.SECONDS); } diff --git a/runelite-client/src/main/java/net/runelite/client/game/ClanManager.java b/runelite-client/src/main/java/net/runelite/client/game/ClanManager.java index 2d5bbe832c..b758d248fb 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/ClanManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ClanManager.java @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.ClanMember; @@ -94,7 +95,7 @@ public class ClanManager } }); - private int modIconsLength; + private int offset; @Inject private ClanManager( @@ -115,6 +116,7 @@ public class ClanManager return clanRanksCache.getUnchecked(playerName); } + @Nullable public BufferedImage getClanImage(final ClanMemberRank clanMemberRank) { if (clanMemberRank == ClanMemberRank.UNRANKED) @@ -127,13 +129,12 @@ public class ClanManager public int getIconNumber(final ClanMemberRank clanMemberRank) { - return modIconsLength - CLANCHAT_IMAGES.length + clanMemberRank.ordinal() - 1; + return offset + clanMemberRank.ordinal() - 1; } private void onGameStateChanged(GameStateChanged gameStateChanged) { - if (gameStateChanged.getGameState() == GameState.LOGGED_IN - && modIconsLength == 0) + if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN && offset == 0) { loadClanChatIcons(); } @@ -146,19 +147,31 @@ public class ClanManager private void loadClanChatIcons() { - final IndexedSprite[] modIcons = client.getModIcons(); - final IndexedSprite[] newModIcons = Arrays.copyOf(modIcons, modIcons.length + CLANCHAT_IMAGES.length); - int curPosition = newModIcons.length - CLANCHAT_IMAGES.length; - - for (int i = 0; i < CLANCHAT_IMAGES.length; i++, curPosition++) { - final int resource = CLANCHAT_IMAGES[i]; - clanChatImages[i] = clanChatImageFromSprite(spriteManager.getSprite(resource, 0)); - newModIcons[curPosition] = ImageUtil.getImageIndexedSprite(clanChatImages[i], client); + IndexedSprite[] modIcons = client.getModIcons(); + offset = modIcons.length; + + IndexedSprite blank = ImageUtil.getImageIndexedSprite( + new BufferedImage(modIcons[0].getWidth(), modIcons[0].getHeight(), BufferedImage.TYPE_INT_ARGB), + client); + + modIcons = Arrays.copyOf(modIcons, offset + CLANCHAT_IMAGES.length); + Arrays.fill(modIcons, offset, modIcons.length, blank); + + client.setModIcons(modIcons); } - client.setModIcons(newModIcons); - modIconsLength = newModIcons.length; + for (int i = 0; i < CLANCHAT_IMAGES.length; i++) + { + final int fi = i; + + spriteManager.getSpriteAsync(CLANCHAT_IMAGES[i], 0, sprite -> + { + IndexedSprite[] modIcons = client.getModIcons(); + clanChatImages[fi] = clanChatImageFromSprite(sprite); + modIcons[offset + fi] = ImageUtil.getImageIndexedSprite(clanChatImages[fi], client); + }); + } } private static String sanitize(String lookup) diff --git a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java index 59c6d72a00..b928b910dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java @@ -92,7 +92,7 @@ public class ChatboxPanelManager private void unsafeCloseInput() { client.runScript( - ScriptID.RESET_CHATBOX_INPUT, + ScriptID.MESSAGE_LAYER_CLOSE, 0, 1 ); @@ -104,7 +104,7 @@ public class ChatboxPanelManager private void unsafeOpenInput(ChatboxInput input) { - client.runScript(ScriptID.CLEAR_CHATBOX_PANEL); + client.runScript(ScriptID.MESSAGE_LAYER_OPEN, 0); // eventBus.register(input); if (input instanceof KeyListener) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/BankSearch.java b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/BankSearch.java index 73bfbc99a4..10a1ed2004 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/BankSearch.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/BankSearch.java @@ -37,20 +37,6 @@ import net.runelite.client.callback.ClientThread; public class BankSearch { - // Widget indexes for searching - private static final int INNER_CONTAINER_IDX = 2; - private static final int SETTINGS_IDX = 4; - private static final int ITEM_CONTAINER_IDX = 7; - private static final int SCROLLBAR_IDX = 8; - private static final int BOTTOM_BAR_IDX = 9; - private static final int SEARCH_BUTTON_BACKGROUND_IDX = 15; - private static final int TITLE_BAR_IDX = 16; - private static final int ITEM_COUNT_IDX = 17; - private static final int TAB_BAR_IDX = 18; - private static final int INCINERATOR_IDX = 19; - private static final int INCINERATOR_CONFIRM_IDX = 20; - private static final int HIDDEN_WIDGET_IDX = 21; - private final Client client; private final ClientThread clientThread; @@ -64,51 +50,38 @@ public class BankSearch this.clientThread = clientThread; } - public void search(InputType inputType, String search, Boolean closeInput) + public void search(InputType inputType, String search, boolean closeInput) { clientThread.invoke(() -> { - Widget bankContainer = client.getWidget(WidgetInfo.BANK_CONTAINER); + Widget bankContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); if (bankContainer == null || bankContainer.isHidden()) { return; } - Object[] widgetIds = bankContainer.getOnLoadListener(); + Object[] scriptArgs = bankContainer.getOnInvTransmitListener(); - // In case the widget ids array is incorrect, do not proceed - if (widgetIds == null || widgetIds.length < 21) + if (scriptArgs == null) { return; } + // This ensures that any chatbox input (e.g from search) will not remain visible when // selecting/changing tab if (closeInput) { - client.runScript(ScriptID.RESET_CHATBOX_INPUT, 0, 0); + client.runScript(ScriptID.MESSAGE_LAYER_CLOSE, 0, 0); } client.setVar(VarClientInt.INPUT_TYPE, inputType.getType()); client.setVar(VarClientStr.INPUT_TEXT, search); - client.runScript(ScriptID.BANK_LAYOUT, - WidgetInfo.BANK_CONTAINER.getId(), - widgetIds[INNER_CONTAINER_IDX], - widgetIds[SETTINGS_IDX], - widgetIds[ITEM_CONTAINER_IDX], - widgetIds[SCROLLBAR_IDX], - widgetIds[BOTTOM_BAR_IDX], - widgetIds[TITLE_BAR_IDX], - widgetIds[ITEM_COUNT_IDX], - widgetIds[SEARCH_BUTTON_BACKGROUND_IDX], - widgetIds[TAB_BAR_IDX], - widgetIds[INCINERATOR_IDX], - widgetIds[INCINERATOR_CONFIRM_IDX], - widgetIds[HIDDEN_WIDGET_IDX]); + client.runScript(scriptArgs); }); } - public void reset(Boolean closeChat) + public void reset(boolean closeChat) { search(InputType.NONE, "", closeChat); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java index 43b71dadac..24f4b51093 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java @@ -339,7 +339,7 @@ public class TabInterface { bankSearch.reset(true); - clientThread.invokeLater(() -> client.runScript(ScriptID.RESET_CHATBOX_INPUT, 0, 0)); + clientThread.invokeLater(() -> client.runScript(ScriptID.MESSAGE_LAYER_CLOSE, 0, 0)); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java index 85f4c36a54..65505cdbfd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java @@ -62,7 +62,7 @@ public class ChatboxPerformancePlugin extends Plugin eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent); if (client.getGameState() == GameState.LOGGED_IN) { - clientThread.invokeLater(() -> client.runScript(ScriptID.RESET_CHATBOX_INPUT)); + clientThread.invokeLater(() -> client.runScript(ScriptID.MESSAGE_LAYER_CLOSE, 0, 0)); } } @@ -71,7 +71,7 @@ public class ChatboxPerformancePlugin extends Plugin { if (client.getGameState() == GameState.LOGGED_IN) { - clientThread.invokeLater(() -> client.runScript(ScriptID.RESET_CHATBOX_INPUT)); + clientThread.invokeLater(() -> client.runScript(ScriptID.MESSAGE_LAYER_CLOSE, 0, 0)); } eventBus.unregister(this); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index 178c441245..9bc0b57204 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -73,9 +73,6 @@ public class ChatNotificationsPlugin extends Plugin @Inject private Notifier notifier; - @Inject - private RuneLiteProperties runeLiteProperties; - @Inject private EventBus eventBus; @@ -183,7 +180,7 @@ public class ChatNotificationsPlugin extends Plugin break; case CONSOLE: // Don't notify for notification messages - if (chatMessage.getName().equals(runeLiteProperties.getTitle())) + if (chatMessage.getName().equals(RuneLiteProperties.getTitle())) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java index 087b51d95e..b4a4192ad0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java @@ -95,9 +95,6 @@ public class DiscordPlugin extends Plugin @Inject private ClientToolbar clientToolbar; - @Inject - private RuneLiteProperties properties; - @Inject private DiscordState discordState; @@ -148,7 +145,7 @@ public class DiscordPlugin extends Plugin .tab(false) .tooltip("Join Discord") .icon(icon) - .onClick(() -> LinkBrowser.browse(properties.getDiscordInvite())) + .onClick(() -> LinkBrowser.browse(RuneLiteProperties.getDiscordInvite())) .build(); clientToolbar.addNavigation(discordButton); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java index 93c3c1b28c..6133601d5c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java @@ -58,16 +58,14 @@ class DiscordState private final DiscordService discordService; private final DiscordPlugin plugin; private final PartyService party; - private final RuneLiteProperties properties; private DiscordPresence lastPresence; @Inject - private DiscordState(final DiscordService discordService, final DiscordPlugin plugin, final PartyService party, final RuneLiteProperties properties) + private DiscordState(final DiscordService discordService, final DiscordPlugin plugin, final PartyService party) { this.discordService = discordService; this.plugin = plugin; this.party = party; - this.properties = properties; } /** @@ -173,12 +171,12 @@ class DiscordState } // Replace snapshot with + to make tooltip shorter (so it will span only 1 line) - final String versionShortHand = properties.getVersion().replace("-SNAPSHOT", "+"); + final String versionShortHand = RuneLiteProperties.getVersion().replace("-SNAPSHOT", "+"); final DiscordPresence.DiscordPresenceBuilder presenceBuilder = DiscordPresence.builder() .state(MoreObjects.firstNonNull(state, "")) .details(MoreObjects.firstNonNull(details, "")) - .largeImageText(properties.getTitle() + " v" + versionShortHand) + .largeImageText(RuneLiteProperties.getTitle() + " v" + versionShortHand) .startTimestamp(event.getStart()) .smallImageKey(imageKey) .partyMax(PARTY_MAX) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java index 7e5cf64195..3a200eb840 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPanel.java @@ -51,7 +51,6 @@ import static net.runelite.client.RuneLite.LOGS_DIR; import net.runelite.client.RuneLiteProperties; import net.runelite.client.account.SessionManager; import net.runelite.client.config.ConfigManager; -import net.runelite.client.eventbus.EventBus; import net.runelite.client.events.SessionClose; import net.runelite.client.events.SessionOpen; import net.runelite.client.ui.ColorScheme; @@ -81,12 +80,6 @@ public class InfoPanel extends PluginPanel @Nullable private Client client; - @Inject - private RuneLiteProperties runeLiteProperties; - - @Inject - private EventBus eventBus; - @Inject private SessionManager sessionManager; @@ -119,10 +112,10 @@ public class InfoPanel extends PluginPanel final Font smallFont = FontManager.getRunescapeSmallFont(); - JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion())); + JLabel version = new JLabel(htmlLabel("RuneLite version: ", RuneLiteProperties.getVersion())); version.setFont(smallFont); - JLabel plusVersion = new JLabel(htmlLabel("RuneLitePlus version: ", runeLiteProperties.getPlusVersion())); + JLabel plusVersion = new JLabel(htmlLabel("RuneLitePlus version: ", RuneLiteProperties.getPlusVersion())); version.setFont(smallFont); JLabel revision = new JLabel(); @@ -177,14 +170,13 @@ public class InfoPanel extends PluginPanel actionsContainer.add(buildLinkPanel(GITHUB_ICON, "License info", "for distribution", "https://github.com/runelite-extended/runelite/blob/master/LICENSE")); actionsContainer.add(buildLinkPanel(FOLDER_ICON, "Open logs directory", "(for bug reports)", LOGS_DIR)); actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", "https://discord.gg/HN5gf3m")); - actionsContainer.add(buildLinkPanel(PATREON_ICON, "Patreon to support", "the RuneLitePlus devs", runeLiteProperties.getPatreonLink())); + actionsContainer.add(buildLinkPanel(PATREON_ICON, "Patreon to support", "the RuneLitePlus devs", RuneLiteProperties.getPatreonLink())); /* actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", runeLiteProperties.getWikiLink()));*/ add(versionPanel, BorderLayout.NORTH); add(actionsContainer, BorderLayout.CENTER); updateLoggedIn(); - // eventBus.register(this); } /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index 703db01347..4dfd93ef6c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -44,6 +44,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -1151,18 +1152,17 @@ public class LootTrackerPlugin extends Plugin private Collection convertToLootTrackerRecord(final Collection records) { - Collection trackerRecords = new ArrayList<>(); - for (LootRecord record : records) - { - LootTrackerItem[] drops = record.getDrops().stream().map(itemStack -> - buildLootTrackerItem(itemStack.getId(), itemStack.getQty()) - ).toArray(LootTrackerItem[]::new); - - trackerRecords.add(new LootTrackerRecord(record.getEventId(), record.getUsername(), - "", drops, record.getTime())); - } - - return trackerRecords; + return records.stream() + .sorted(Comparator.comparing(LootRecord::getTime)) + .map(record -> + { + LootTrackerItem[] drops = record.getDrops().stream().map(itemStack -> + buildLootTrackerItem(itemStack.getId(), itemStack.getQty()) + ).toArray(LootTrackerItem[]::new); + return new LootTrackerRecord(record.getEventId(), record.getUsername(), + "", drops, record.getTime()); + }) + .collect(Collectors.toCollection(ArrayList::new)); } private Collection convertToLTItemEntries(Collection stacks) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java index f694be8ef4..0294bb883b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java @@ -43,7 +43,6 @@ import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.ui.ClientUI; @PluginDescriptor( loadWhenOutdated = true, // prevent users from disabling @@ -77,8 +76,6 @@ public class RuneLitePlusPlugin extends Plugin protected void startUp() throws Exception { addSubscriptions(); - ClientUI.currentPresenceName = ("RuneLitePlus"); - ClientUI.frame.setTitle(ClientUI.currentPresenceName); entered = -1; enterIdx = 0; @@ -103,7 +100,7 @@ public class RuneLitePlusPlugin extends Plugin return; } - else if (!config.keyboardPin()) + if (!config.keyboardPin()) { entered = 0; enterIdx = 0; diff --git a/runelite-client/src/main/java/net/runelite/client/rs/VerificationException.java b/runelite-client/src/main/java/net/runelite/client/rs/VerificationException.java index 040370e8f0..4138a12fd3 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/VerificationException.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/VerificationException.java @@ -24,7 +24,7 @@ */ package net.runelite.client.rs; -class VerificationException extends Exception +public class VerificationException extends Exception { public VerificationException(String message) { diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index 68e11fe05a..75e0ae4424 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -60,7 +60,6 @@ import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JOptionPane; -import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.INFORMATION_MESSAGE; import javax.swing.JPanel; import javax.swing.JRootPane; @@ -116,13 +115,11 @@ public class ClientUI private static final int CLIENT_WELL_HIDDEN_MARGIN = 160; private static final int CLIENT_WELL_HIDDEN_MARGIN_TOP = 10; public static boolean allowInput = false; - public static String currentPresenceName = "RuneLitePlus"; public static final BufferedImage ICON = ImageUtil.getResourceStreamFromClass(ClientUI.class, "/runeliteplus.png"); @Getter private TrayIcon trayIcon; - private final RuneLiteProperties properties; private final RuneLiteConfig config; private final KeyManager keyManager; private final MouseManager mouseManager; @@ -152,7 +149,6 @@ public class ClientUI @Inject private ClientUI( - RuneLiteProperties properties, RuneLiteConfig config, KeyManager keyManager, MouseManager mouseManager, @@ -161,7 +157,6 @@ public class ClientUI Provider clientThreadProvider, EventBus eventbus) { - this.properties = properties; this.config = config; this.keyManager = keyManager; this.mouseManager = mouseManager; @@ -305,18 +300,17 @@ public class ClientUI return false; } - frame.setTitle(currentPresenceName + " - " + name); + frame.setTitle(RuneLiteProperties.getTitle() + " - " + name); return true; }); } /** * Initialize UI. - * * @param runelite runelite instance that will be shut down on exit * @throws Exception exception that can occur during creation of the UI */ - public void open(final RuneLite runelite) throws Exception + public void init(final RuneLite runelite) throws Exception { SwingUtilities.invokeAndWait(() -> { @@ -328,7 +322,7 @@ public class ClientUI // Try to enable fullscreen on OSX OSXUtil.tryEnableFullscreen(frame); - frame.setTitle(ClientUI.currentPresenceName); + frame.setTitle(RuneLiteProperties.getTitle()); frame.setIconImage(ICON); frame.getLayeredPane().setCursor(Cursor.getDefaultCursor()); // Prevent substance from using a resize cursor for pointing frame.setLocationRelativeTo(frame.getOwner()); @@ -465,13 +459,19 @@ public class ClientUI titleToolbar.addComponent(sidebarNavigationButton, sidebarNavigationJButton); toggleSidebar(); + }); + } + public void show() + { + SwingUtilities.invokeLater(() -> + { // Layout frame frame.pack(); frame.revalidateMinimumSize(); // Create tray icon (needs to be created after frame is packed) - trayIcon = SwingUtil.createTrayIcon(ICON, properties.getTitle(), frame); + trayIcon = SwingUtil.createTrayIcon(ICON, RuneLiteProperties.getTitle(), frame); // Move frame around (needs to be done after frame is packed) if (config.rememberScreenBounds()) @@ -528,14 +528,7 @@ public class ClientUI }); // Show out of date dialog if needed - if (client == null) - { - SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(frame, - "Error loading client! Check your logs for more details.", - "Unable to load client", - ERROR_MESSAGE)); - } - else if (!(client instanceof Client)) + if (client != null && !(client instanceof Client)) { SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(frame, "RuneLite has not yet been updated to work with the latest\n" @@ -615,7 +608,7 @@ public class ClientUI } /** - * Changes cursor for client window. Requires ${@link ClientUI#open(RuneLite)} to be called first. + * Changes cursor for client window. Requires ${@link ClientUI#init(RuneLite)} to be called first. * FIXME: This is working properly only on Windows, Linux and Mac are displaying cursor incorrectly * * @param image cursor image @@ -854,12 +847,12 @@ public class ClientUI if (player != null && player.getName() != null) { - frame.setTitle(currentPresenceName + " - " + player.getName()); + frame.setTitle(RuneLiteProperties.getTitle() + " - " + player.getName()); } } else { - frame.setTitle(currentPresenceName); + frame.setTitle(RuneLiteProperties.getTitle()); } if (frame.isAlwaysOnTopSupported()) diff --git a/runelite-client/src/main/resources/runelite.plus.properties b/runelite-client/src/main/resources/runelite.plus.properties index d9a0701f7e..8c82b04457 100644 --- a/runelite-client/src/main/resources/runelite.plus.properties +++ b/runelite-client/src/main/resources/runelite.plus.properties @@ -7,4 +7,7 @@ runelite.wiki.link=https://github.com/runelite-extended/runelite/wiki runelite.patreon.link=https://www.patreon.com/RuneLitePlus runelite.plus.title=RuneLitePlus runelite.plus.version=@runelite.plus.version@ -runelite.plus.builddate=@runelite.plus.builddate@ \ No newline at end of file +runelite.plus.builddate=@runelite.plus.builddate@ +runelite.wiki.troubleshooting.link=https://github.com/runelite/runelite/wiki/Troubleshooting-problems-with-the-client +runelite.wiki.building.link=https://github.com/runelite-extended/runelite/wiki/Building-with-IntelliJ-IDEA +runelite.dnschange.link=https://1.1.1.1/dns/ \ No newline at end of file diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java index 40b6bca9b5..6fb2171c93 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/ScriptVMMixin.java @@ -142,12 +142,12 @@ public abstract class ScriptVMMixin implements RSClient @Inject @Override - public void runScript(int id, Object... args) + public void runScript(Object... args) { assert isClientThread(); assert currentScript == null; Object[] cargs = new Object[args.length + 1]; - cargs[0] = id; + // cargs[0] = id; System.arraycopy(args, 0, cargs, 1, args.length); RSScriptEvent se = createScriptEvent(); se.setArguments(cargs);