From 7dd504fdf524afb6cbdc0d864a09f2dc7347e56a Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 20 Dec 2021 18:28:18 -0500 Subject: [PATCH 01/17] http-service: remove cache controller This has never been used and just encourages misuse due to how expensive the requests are --- .../net/runelite/http/api/cache/Cache.java | 104 -------- .../runelite/http/api/cache/CacheArchive.java | 97 ------- .../runelite/http/api/cache/CacheIndex.java | 85 ------ .../http/service/cache/CacheController.java | 251 ------------------ 4 files changed, 537 deletions(-) delete mode 100644 http-api/src/main/java/net/runelite/http/api/cache/Cache.java delete mode 100644 http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java delete mode 100644 http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java delete mode 100644 http-service/src/main/java/net/runelite/http/service/cache/CacheController.java diff --git a/http-api/src/main/java/net/runelite/http/api/cache/Cache.java b/http-api/src/main/java/net/runelite/http/api/cache/Cache.java deleted file mode 100644 index 0fe91d6f98..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/cache/Cache.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * 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.http.api.cache; - -import java.time.Instant; -import java.util.Objects; - -public class Cache -{ - private final int id; - private final int revision; - private final Instant date; - - public Cache(int id, int revision, Instant date) - { - this.id = id; - this.revision = revision; - this.date = date; - } - - @Override - public String toString() - { - return "Cache{" + "id=" + id + ", revision=" + revision + ", date=" + date + '}'; - } - - @Override - public int hashCode() - { - int hash = 5; - hash = 29 * hash + this.id; - hash = 29 * hash + this.revision; - hash = 29 * hash + Objects.hashCode(this.date); - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final Cache other = (Cache) obj; - if (this.id != other.id) - { - return false; - } - if (this.revision != other.revision) - { - return false; - } - if (!Objects.equals(this.date, other.date)) - { - return false; - } - return true; - } - - public int getId() - { - return id; - } - - public int getRevision() - { - return revision; - } - - public Instant getDate() - { - return date; - } -} diff --git a/http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java b/http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java deleted file mode 100644 index a642f1fe4e..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * 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.http.api.cache; - -public class CacheArchive -{ - private final int archiveId; - private final int nameHash; - private final int revision; - - public CacheArchive(int archiveId, int nameHash, int revision) - { - this.archiveId = archiveId; - this.nameHash = nameHash; - this.revision = revision; - } - - @Override - public String toString() - { - return "CacheArchive{" + "archiveId=" + archiveId + ", nameHash=" + nameHash + ", revision=" + revision + '}'; - } - - @Override - public int hashCode() - { - int hash = 5; - hash = 71 * hash + this.archiveId; - hash = 71 * hash + this.nameHash; - hash = 71 * hash + this.revision; - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final CacheArchive other = (CacheArchive) obj; - if (this.archiveId != other.archiveId) - { - return false; - } - if (this.nameHash != other.nameHash) - { - return false; - } - if (this.revision != other.revision) - { - return false; - } - return true; - } - - public int getArchiveId() - { - return archiveId; - } - - public int getNameHash() - { - return nameHash; - } - - public int getRevision() - { - return revision; - } -} diff --git a/http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java b/http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java deleted file mode 100644 index 17558e4531..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * 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.http.api.cache; - -public class CacheIndex -{ - private final int indexId; - private final int revision; - - public CacheIndex(int indexId, int revision) - { - this.indexId = indexId; - this.revision = revision; - } - - @Override - public String toString() - { - return "CacheIndex{" + "indexId=" + indexId + ", revision=" + revision + '}'; - } - - @Override - public int hashCode() - { - int hash = 5; - hash = 61 * hash + this.indexId; - hash = 61 * hash + this.revision; - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final CacheIndex other = (CacheIndex) obj; - if (this.indexId != other.indexId) - { - return false; - } - if (this.revision != other.revision) - { - return false; - } - return true; - } - - public int getIndexId() - { - return indexId; - } - - public int getRevision() - { - return revision; - } -} diff --git a/http-service/src/main/java/net/runelite/http/service/cache/CacheController.java b/http-service/src/main/java/net/runelite/http/service/cache/CacheController.java deleted file mode 100644 index 8cbb3393fc..0000000000 --- a/http-service/src/main/java/net/runelite/http/service/cache/CacheController.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * 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.http.service.cache; - -import java.io.IOException; -import java.util.List; -import java.util.stream.Collectors; -import net.runelite.cache.ConfigType; -import net.runelite.cache.IndexType; -import net.runelite.cache.definitions.ItemDefinition; -import net.runelite.cache.definitions.NpcDefinition; -import net.runelite.cache.definitions.ObjectDefinition; -import net.runelite.cache.definitions.loaders.ItemLoader; -import net.runelite.cache.definitions.loaders.NpcLoader; -import net.runelite.cache.definitions.loaders.ObjectLoader; -import net.runelite.cache.fs.ArchiveFiles; -import net.runelite.cache.fs.FSFile; -import net.runelite.http.api.cache.Cache; -import net.runelite.http.api.cache.CacheArchive; -import net.runelite.http.api.cache.CacheIndex; -import net.runelite.http.service.cache.beans.ArchiveEntry; -import net.runelite.http.service.cache.beans.CacheEntry; -import net.runelite.http.service.cache.beans.IndexEntry; -import net.runelite.http.service.util.exception.NotFoundException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/cache") -public class CacheController -{ - @Autowired - private CacheService cacheService; - - @GetMapping("/") - public List listCaches() - { - return cacheService.listCaches().stream() - .map(entry -> new Cache(entry.getId(), entry.getRevision(), entry.getDate())) - .collect(Collectors.toList()); - } - - @GetMapping("{cacheId}") - public List listIndexes(@PathVariable int cacheId) - { - CacheEntry cache = cacheService.findCache(cacheId); - if (cache == null) - { - throw new NotFoundException(); - } - - List indexes = cacheService.findIndexesForCache(cache); - - return indexes.stream() - .map(entry -> new CacheIndex(entry.getIndexId(), entry.getRevision())) - .collect(Collectors.toList()); - } - - @GetMapping("{cacheId}/{indexId}") - public List listArchives(@PathVariable int cacheId, - @PathVariable int indexId) - { - CacheEntry cache = cacheService.findCache(cacheId); - if (cache == null) - { - throw new NotFoundException(); - } - - IndexEntry indexEntry = cacheService.findIndexForCache(cache, indexId); - if (indexEntry == null) - { - throw new NotFoundException(); - } - - List archives = cacheService.findArchivesForIndex(indexEntry); - - return archives.stream() - .map(archive -> new CacheArchive(archive.getArchiveId(), archive.getNameHash(), archive.getRevision())) - .collect(Collectors.toList()); - } - - @GetMapping("{cacheId}/{indexId}/{archiveId}") - public CacheArchive getCacheArchive(@PathVariable int cacheId, - @PathVariable int indexId, - @PathVariable int archiveId) - { - CacheEntry cache = cacheService.findCache(cacheId); - if (cache == null) - { - throw new NotFoundException(); - } - - IndexEntry indexEntry = cacheService.findIndexForCache(cache, indexId); - if (indexEntry == null) - { - throw new NotFoundException(); - } - - ArchiveEntry archiveEntry = cacheService.findArchiveForIndex(indexEntry, archiveId); - if (archiveEntry == null) - { - throw new NotFoundException(); - } - - return new CacheArchive(archiveEntry.getArchiveId(), - archiveEntry.getNameHash(), archiveEntry.getRevision()); - } - - @GetMapping("{cacheId}/{indexId}/{archiveId}/data") - public byte[] getArchiveData( - @PathVariable int cacheId, - @PathVariable int indexId, - @PathVariable int archiveId - ) - { - CacheEntry cache = cacheService.findCache(cacheId); - if (cache == null) - { - throw new NotFoundException(); - } - - IndexEntry indexEntry = cacheService.findIndexForCache(cache, indexId); - if (indexEntry == null) - { - throw new NotFoundException(); - } - - ArchiveEntry archiveEntry = cacheService.findArchiveForIndex(indexEntry, archiveId); - if (archiveEntry == null) - { - throw new NotFoundException(); - } - - return cacheService.getArchive(archiveEntry); - } - - private ArchiveEntry findConfig(ConfigType config) - { - CacheEntry cache = cacheService.findMostRecent(); - if (cache == null) - { - throw new NotFoundException(); - } - - IndexEntry indexEntry = cacheService.findIndexForCache(cache, IndexType.CONFIGS.getNumber()); - if (indexEntry == null) - { - throw new NotFoundException(); - } - - ArchiveEntry archiveEntry = cacheService.findArchiveForIndex(indexEntry, config.getId()); - if (archiveEntry == null) - { - throw new NotFoundException(); - } - - return archiveEntry; - } - - @GetMapping("item/{itemId}") - public ItemDefinition getItem(@PathVariable int itemId) throws IOException - { - ArchiveEntry archiveEntry = findConfig(ConfigType.ITEM); - - ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry); - if (archiveFiles == null) - { - throw new NotFoundException(); - } - - FSFile file = archiveFiles.findFile(itemId); - if (file == null) - { - throw new NotFoundException(); - } - - ItemDefinition itemdef = new ItemLoader().load(itemId, file.getContents()); - return itemdef; - } - - @GetMapping("object/{objectId}") - public ObjectDefinition getObject( - @PathVariable int objectId - ) throws IOException - { - ArchiveEntry archiveEntry = findConfig(ConfigType.OBJECT); - - ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry); - if (archiveFiles == null) - { - throw new NotFoundException(); - } - - FSFile file = archiveFiles.findFile(objectId); - if (file == null) - { - throw new NotFoundException(); - } - - ObjectDefinition objectdef = new ObjectLoader().load(objectId, file.getContents()); - return objectdef; - } - - @GetMapping("npc/{npcId}") - public NpcDefinition getNpc( - @PathVariable int npcId - ) throws IOException - { - ArchiveEntry archiveEntry = findConfig(ConfigType.NPC); - - ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry); - if (archiveFiles == null) - { - throw new NotFoundException(); - } - - FSFile file = archiveFiles.findFile(npcId); - if (file == null) - { - throw new NotFoundException(); - } - - NpcDefinition npcdef = new NpcLoader().load(npcId, file.getContents()); - return npcdef; - } -} From 171d9bb7cf4088a1ac158eee3bf71fd4b192dc51 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 20 Dec 2021 18:33:03 -0500 Subject: [PATCH 02/17] scripts: remove scripts These aren't used anymore --- scripts/deploy-vanilla.sh | 9 -------- scripts/pom.xml | 43 --------------------------------------- 2 files changed, 52 deletions(-) delete mode 100755 scripts/deploy-vanilla.sh delete mode 100644 scripts/pom.xml diff --git a/scripts/deploy-vanilla.sh b/scripts/deploy-vanilla.sh deleted file mode 100755 index 444331fa6c..0000000000 --- a/scripts/deploy-vanilla.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -if [ "$#" -ne 2 ] ; then - exit 1 -fi - -echo "Deploying vanilla version $1 ($2) to repo.runelite.net" - -mvn deploy:deploy-file -DgroupId=net.runelite.rs -DartifactId=vanilla -Dversion=$1 -Dfile=$2 -DrepositoryId=runelite -Durl=dav:http://repo.runelite.net diff --git a/scripts/pom.xml b/scripts/pom.xml deleted file mode 100644 index 7898c2e8fb..0000000000 --- a/scripts/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - 4.0.0 - - net.runelite - scripts - 1.0.0 - Scripts - - - - - org.apache.maven.wagon - wagon-webdav-jackrabbit - 2.12 - - - - From 6901adc2ffa7610603cbbdba7a0f2071ff3954a1 Mon Sep 17 00:00:00 2001 From: Wayne Li Date: Sat, 18 Dec 2021 01:08:38 -0800 Subject: [PATCH 03/17] HotColdClue: Delete Twisted Leagues code --- .../plugins/cluescrolls/clues/HotColdClue.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java index aa2e397f99..ec934a7d6d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java @@ -66,10 +66,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat "Jorral", "Speak to Jorral to receive a strange device.", new WorldPoint(2436, 3347, 0)); - private static final HotColdClue MASTER_CLUE_LEAGUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Watson may have a clue.", - "Watson", - "Speak to Watson to receive a strange device.", - new WorldPoint(1645, 3572, 0)); private final String text; private final String npc; @@ -91,11 +87,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat MASTER_CLUE.reset(); return MASTER_CLUE; } - else if (MASTER_CLUE_LEAGUE.text.equalsIgnoreCase(text)) - { - MASTER_CLUE_LEAGUE.reset(); - return MASTER_CLUE_LEAGUE; - } return null; } @@ -290,7 +281,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat { temperatureSet = HotColdTemperature.BEGINNER_HOT_COLD_TEMPERATURES; } - else if (this == MASTER_CLUE || this == MASTER_CLUE_LEAGUE) + else if (this == MASTER_CLUE) { temperatureSet = HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES; } @@ -314,9 +305,8 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat return false; } - boolean master = this == MASTER_CLUE || this == MASTER_CLUE_LEAGUE; if ((this == BEGINNER_CLUE && temperature == HotColdTemperature.BEGINNER_VISIBLY_SHAKING) - || (master && temperature == HotColdTemperature.MASTER_VISIBLY_SHAKING)) + || (this == MASTER_CLUE && temperature == HotColdTemperature.MASTER_VISIBLY_SHAKING)) { markFinalSpot(localWorld); } @@ -346,7 +336,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat { isBeginner = true; } - else if (this == MASTER_CLUE || this == MASTER_CLUE_LEAGUE) + else if (this == MASTER_CLUE) { isBeginner = false; } From 50a2d2f73f9e443797e613a301cf810a7d88c016 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Dec 2021 23:01:34 -0500 Subject: [PATCH 04/17] config manager: increase sendConfig delay to 5 minutes --- .../src/main/java/net/runelite/client/config/ConfigManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index 1f14b5a504..ee037cb404 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -157,7 +157,7 @@ public class ConfigManager this.propertiesFile = getPropertiesFile(); this.gson = gson; - scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS); + scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 5 * 60, TimeUnit.SECONDS); } public String getRSProfileKey() From c1aa0c4898900361593e423792b475c08f141e49 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Dec 2021 11:29:02 -0500 Subject: [PATCH 05/17] client: move jagexcache into .runelite --- .../java/net/runelite/client/RuneLite.java | 65 +++++++++++++++++++ .../net/runelite/client/ui/ClientPanel.java | 6 -- 2 files changed, 65 insertions(+), 6 deletions(-) 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 142c4570c3..1d314f44ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -30,15 +30,21 @@ import com.google.common.annotations.VisibleForTesting; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; +import java.applet.Applet; import java.io.File; +import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.cert.X509Certificate; import java.util.Locale; +import java.util.stream.Stream; import javax.annotation.Nullable; import javax.inject.Provider; import javax.inject.Singleton; @@ -55,6 +61,7 @@ import joptsimple.util.EnumConverter; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; +import net.runelite.api.Constants; import net.runelite.client.account.SessionManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.discord.DiscordService; @@ -127,6 +134,10 @@ public class RuneLite @Inject private Provider worldMapOverlay; + @Inject + @Nullable + private Applet applet; + @Inject @Nullable private Client client; @@ -279,6 +290,28 @@ public class RuneLite injector.injectMembers(client); } + // Start the applet + if (applet != null) + { + copyJagexCache(); + + // Client size must be set prior to init + applet.setSize(Constants.GAME_FIXED_SIZE); + + // Change user.home so the client places jagexcache in the .runelite directory + String oldHome = System.setProperty("user.home", RUNELITE_DIR.getAbsolutePath()); + try + { + applet.init(); + } + finally + { + System.setProperty("user.home", oldHome); + } + + applet.start(); + } + SplashScreen.stage(.57, null, "Loading configuration"); // Load user configuration @@ -433,4 +466,36 @@ public class RuneLite log.warn("unable to setup insecure trust manager", ex); } } + + private static void copyJagexCache() + { + Path from = Paths.get(System.getProperty("user.home"), "jagexcache"); + Path to = Paths.get(System.getProperty("user.home"), ".runelite", "jagexcache"); + if (Files.exists(to) || !Files.exists(from)) + { + return; + } + + log.info("Copying jagexcache from {} to {}", from, to); + + // Recursively copy path https://stackoverflow.com/a/50418060 + try (Stream stream = Files.walk(from)) + { + stream.forEach(source -> + { + try + { + Files.copy(source, to.resolve(from.relativize(source)), COPY_ATTRIBUTES); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + }); + } + catch (Exception e) + { + log.warn("unable to copy jagexcache", e); + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java index c7ccb1a3ed..1b6354baac 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java @@ -47,12 +47,6 @@ final class ClientPanel extends JPanel return; } - client.setLayout(null); - client.setSize(Constants.GAME_FIXED_SIZE); - - client.init(); - client.start(); - add(client, BorderLayout.CENTER); // This causes the whole game frame to be redrawn each frame instead From 438b4004e7b0805c646c4bea7554405afd6dc4cf Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Dec 2021 23:06:11 -0500 Subject: [PATCH 06/17] config manager: remove migrateConfig --- .../runelite/client/config/ConfigManager.java | 118 ------------------ 1 file changed, 118 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index ee037cb404..b9b3a8503b 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -27,7 +27,6 @@ package net.runelite.client.config; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableSet; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; import com.google.gson.Gson; @@ -57,7 +56,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; -import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; import java.util.Date; @@ -73,10 +71,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.Nullable; import javax.inject.Inject; @@ -307,8 +301,6 @@ public class ConfigManager } } } - - migrateConfig(); } private void syncPropertiesFromFile(File propertiesFile) @@ -1106,114 +1098,4 @@ public class ConfigManager } return new String[]{group, profile, key}; } - - private synchronized void migrateConfig() - { - String migrationKey = "profileMigrationDone"; - if (getConfiguration("runelite", migrationKey) != null) - { - return; - } - - Map profiles = new HashMap<>(); - - AtomicInteger changes = new AtomicInteger(); - List> migrators = new ArrayList<>(); - for (String[] tpl : new String[][] - { - {"(grandexchange)\\.buylimit_(%)\\.(#)", "$1.buylimit.$3"}, - {"(timetracking)\\.(%)\\.(autoweed|contract)", "$1.$3"}, - {"(timetracking)\\.(%)\\.(#\\.#)", "$1.$3"}, - {"(timetracking)\\.(%)\\.(birdhouse)\\.(#)", "$1.$3.$4"}, - {"(killcount|personalbest)\\.(%)\\.([^.]+)", "$1.$3"}, - {"(geoffer)\\.(%)\\.(#)", "$1.$3"}, - }) - { - String replace = tpl[1]; - String pat = ("^" + tpl[0] + "$") - .replace("#", "-?[0-9]+") - .replace("(%)", "(?.*)"); - Pattern p = Pattern.compile(pat); - - migrators.add(oldkey -> - { - Matcher m = p.matcher(oldkey); - if (!m.find()) - { - return false; - } - - String newKey = m.replaceFirst(replace); - String username = m.group("login").toLowerCase(Locale.US); - - if (username.startsWith(RSPROFILE_GROUP + ".")) - { - return false; - } - - String profKey = profiles.computeIfAbsent(username, u -> - findRSProfile(getRSProfiles(), u, RuneScapeProfileType.STANDARD, u, true).getKey()); - - String[] oldKeySplit = splitKey(oldkey); - if (oldKeySplit == null) - { - log.warn("skipping migration of invalid key \"{}\"", oldkey); - return false; - } - if (oldKeySplit[KEY_SPLITTER_PROFILE] != null) - { - log.debug("skipping migrated key \"{}\"", oldkey); - return false; - } - - String[] newKeySplit = splitKey(newKey); - if (newKeySplit == null || newKeySplit[KEY_SPLITTER_PROFILE] != null) - { - log.warn("migration produced a bad key: \"{}\" -> \"{}\"", oldkey, newKey); - return false; - } - - if (changes.getAndAdd(1) <= 0) - { - File file = new File(propertiesFile.getParent(), propertiesFile.getName() + "." + TIME_FORMAT.format(new Date())); - log.info("backing up pre-migration config to {}", file); - try - { - saveToFile(file); - } - catch (IOException e) - { - log.error("Backup failed", e); - throw new RuntimeException(e); - } - } - - String oldGroup = oldKeySplit[KEY_SPLITTER_GROUP]; - String oldKeyPart = oldKeySplit[KEY_SPLITTER_KEY]; - String value = getConfiguration(oldGroup, oldKeyPart); - setConfiguration(newKeySplit[KEY_SPLITTER_GROUP], profKey, newKeySplit[KEY_SPLITTER_KEY], value); - unsetConfiguration(oldGroup, oldKeyPart); - return true; - }); - } - - Set keys = (Set) ImmutableSet.copyOf((Set) properties.keySet()); - keys: - for (String key : keys) - { - for (Predicate mig : migrators) - { - if (mig.test(key)) - { - continue keys; - } - } - } - - if (changes.get() > 0) - { - log.info("migrated {} config keys", changes); - } - setConfiguration("runelite", migrationKey, 1); - } } From ae5614ce6adae2a29a6186cdb50086641370afb1 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 21 Dec 2021 23:22:19 -0500 Subject: [PATCH 07/17] api: remove set/get game drawing mode This is being moved internally --- .../src/main/java/net/runelite/api/Client.java | 14 -------------- .../java/net/runelite/client/ui/ClientPanel.java | 9 --------- 2 files changed, 23 deletions(-) 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 1699b5637d..12ae583c74 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -908,20 +908,6 @@ public interface Client extends GameEngine */ long getOverallExperience(); - /** - * Gets the game drawing mode. - * - * @return the game drawing mode - */ - int getGameDrawingMode(); - - /** - * Sets the games drawing mode. - * - * @param gameDrawingMode the new drawing mode - */ - void setGameDrawingMode(int gameDrawingMode); - /** * Refreshes the chat. */ diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java index 1b6354baac..9b284bf6df 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java @@ -29,7 +29,6 @@ import java.awt.BorderLayout; import java.awt.Color; import javax.annotation.Nullable; import javax.swing.JPanel; -import net.runelite.api.Client; import net.runelite.api.Constants; final class ClientPanel extends JPanel @@ -48,13 +47,5 @@ final class ClientPanel extends JPanel } add(client, BorderLayout.CENTER); - - // This causes the whole game frame to be redrawn each frame instead - // of only the viewport, so we can hook to MainBufferProvider#draw - // and draw anywhere without it leaving artifacts - if (client instanceof Client) - { - ((Client)client).setGameDrawingMode(2); - } } } \ No newline at end of file From 18050c604c9e77ff56bf65e95eddd807a0679c8d Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 22 Dec 2021 15:09:19 +0100 Subject: [PATCH 08/17] project: set GameDrawingMode --- .../java/com/openosrs/injector/Injector.java | 3 ++ .../injectors/raw/GameDrawingMode.java | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java diff --git a/injector/src/main/java/com/openosrs/injector/Injector.java b/injector/src/main/java/com/openosrs/injector/Injector.java index 2264ff15f1..b767970b3f 100644 --- a/injector/src/main/java/com/openosrs/injector/Injector.java +++ b/injector/src/main/java/com/openosrs/injector/Injector.java @@ -18,6 +18,7 @@ import com.openosrs.injector.injectors.RSApiInjector; import com.openosrs.injector.injectors.raw.AddPlayerToMenu; import com.openosrs.injector.injectors.raw.ClearColorBuffer; import com.openosrs.injector.injectors.raw.DrawMenu; +import com.openosrs.injector.injectors.raw.GameDrawingMode; import com.openosrs.injector.injectors.raw.GraphicsObject; import com.openosrs.injector.injectors.raw.Occluder; import com.openosrs.injector.injectors.raw.RasterizerAlpha; @@ -149,6 +150,8 @@ public class Injector extends InjectData implements InjectTaskHandler inject(new DrawMenu(this)); + inject(new GameDrawingMode(this)); + inject(new AddPlayerToMenu(this)); inject(new RuneliteMenuEntry(this)); diff --git a/injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java b/injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java new file mode 100644 index 0000000000..977d304a89 --- /dev/null +++ b/injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java @@ -0,0 +1,50 @@ +package com.openosrs.injector.injectors.raw; + +import com.openosrs.injector.InjectUtil; +import com.openosrs.injector.injection.InjectData; +import com.openosrs.injector.injectors.AbstractInjector; +import java.util.ListIterator; +import net.runelite.asm.ClassFile; +import net.runelite.asm.Method; +import net.runelite.asm.attributes.code.Instruction; +import net.runelite.asm.attributes.code.Instructions; +import net.runelite.asm.attributes.code.instructions.LDC; +import net.runelite.asm.attributes.code.instructions.PutStatic; +import net.runelite.asm.pool.Field; + +public class GameDrawingMode extends AbstractInjector +{ + public GameDrawingMode(InjectData inject) + { + super(inject); + } + + public void inject() + { + final ClassFile clientVanilla = inject.toVanilla( + inject.getDeobfuscated() + .findClass("Client") + ); + final Field gameDrawingMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField(); + + Method clinit = clientVanilla.findMethod(""); + + Instructions ins = clinit.getCode().getInstructions(); + ListIterator iterator = ins.getInstructions().listIterator(); + while (iterator.hasNext()) + { + Instruction i = iterator.next(); + + if (i instanceof PutStatic) + { + Field field = ((PutStatic) i).getField(); + + if (field.getName().equals(gameDrawingMode.getName())) + { + iterator.add(new LDC(ins, 2)); + iterator.add(new PutStatic(ins, gameDrawingMode)); + } + } + } + } +} From f560ec63865c6071905906fa2cbfc2e47ed479e1 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Wed, 22 Dec 2021 15:09:56 +0100 Subject: [PATCH 09/17] project: RuneLiteMenuEntry overritde toString --- runescape-client/src/main/java/RuneLiteMenuEntry.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runescape-client/src/main/java/RuneLiteMenuEntry.java b/runescape-client/src/main/java/RuneLiteMenuEntry.java index 30681ec768..05fca5a859 100644 --- a/runescape-client/src/main/java/RuneLiteMenuEntry.java +++ b/runescape-client/src/main/java/RuneLiteMenuEntry.java @@ -341,4 +341,11 @@ public class RuneLiteMenuEntry implements MenuEntry return hash; } + + @Override + public String toString() + { + return "MenuEntryImpl(getOption=" + this.getOption() + ", getTarget=" + this.getTarget() + ", getIdentifier=" + this.getIdentifier() + ", getType=" + this.getType() + ", getParam0=" + this.getParam0() + ", getParam1=" + this.getParam1() + ", isForceLeftClick=" + this.isForceLeftClick() + ", isDeprioritized=" + this.isDeprioritized() + ")"; + + } } From b6e17cd15e74fa3ad96eb181618b7924ca127a60 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 22 Dec 2021 12:46:52 -0500 Subject: [PATCH 10/17] http-service: move several hardcoded urls to config Also make an OkHttpClient bean and use it everywhere --- .../service/SpringBootWebApplication.java | 9 ++++-- .../runelite/http/service/account/State.java | 22 ++------------ .../http/service/feed/blog/BlogService.java | 22 +++++++++++--- .../feed/osrsnews/OSRSNewsService.java | 22 +++++++++++--- .../service/feed/twitter/TwitterService.java | 10 +++++-- .../http/service/item/ItemService.java | 29 ++++++++++++------- .../http/service/wiki/WikiPriceService.java | 19 +++++++----- .../http/service/worlds/WorldsService.java | 29 ++++++++++--------- .../src/main/resources/application.yaml | 9 ++++++ .../service/worlds/WorldsServiceTest.java | 4 +-- 10 files changed, 109 insertions(+), 66 deletions(-) diff --git a/http-service/src/main/java/net/runelite/http/service/SpringBootWebApplication.java b/http-service/src/main/java/net/runelite/http/service/SpringBootWebApplication.java index c4d46210b8..6d045b8231 100644 --- a/http-service/src/main/java/net/runelite/http/service/SpringBootWebApplication.java +++ b/http-service/src/main/java/net/runelite/http/service/SpringBootWebApplication.java @@ -68,7 +68,7 @@ import org.sql2o.quirks.NoQuirks; public class SpringBootWebApplication extends SpringBootServletInitializer { @Bean - protected ServletContextListener listener() + protected ServletContextListener listener(OkHttpClient client) { return new ServletContextListener() { @@ -82,7 +82,6 @@ public class SpringBootWebApplication extends SpringBootServletInitializer public void contextDestroyed(ServletContextEvent sce) { // Destroy okhttp client - OkHttpClient client = RuneLiteAPI.CLIENT; client.dispatcher().executorService().shutdown(); client.connectionPool().evictAll(); try @@ -200,6 +199,12 @@ public class SpringBootWebApplication extends SpringBootServletInitializer } } + @Bean + public OkHttpClient okHttpClient() + { + return RuneLiteAPI.CLIENT; + } + public static void main(String[] args) { SpringApplication.run(SpringBootWebApplication.class, args); diff --git a/http-service/src/main/java/net/runelite/http/service/account/State.java b/http-service/src/main/java/net/runelite/http/service/account/State.java index 50b47b2c19..1412efa11a 100644 --- a/http-service/src/main/java/net/runelite/http/service/account/State.java +++ b/http-service/src/main/java/net/runelite/http/service/account/State.java @@ -25,29 +25,11 @@ package net.runelite.http.service.account; import java.util.UUID; +import lombok.Data; +@Data public class State { private UUID uuid; private String apiVersion; - - public UUID getUuid() - { - return uuid; - } - - public void setUuid(UUID uuid) - { - this.uuid = uuid; - } - - public String getApiVersion() - { - return apiVersion; - } - - public void setApiVersion(String apiVersion) - { - this.apiVersion = apiVersion; - } } diff --git a/http-service/src/main/java/net/runelite/http/service/feed/blog/BlogService.java b/http-service/src/main/java/net/runelite/http/service/feed/blog/BlogService.java index 9da6cc171b..72f7938910 100644 --- a/http-service/src/main/java/net/runelite/http/service/feed/blog/BlogService.java +++ b/http-service/src/main/java/net/runelite/http/service/feed/blog/BlogService.java @@ -33,13 +33,15 @@ import java.util.List; import java.util.Locale; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.feed.FeedItem; import net.runelite.http.api.feed.FeedItemType; import net.runelite.http.service.util.exception.InternalServerErrorException; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -50,16 +52,28 @@ import org.xml.sax.SAXException; @Service public class BlogService { - private static final HttpUrl RSS_URL = HttpUrl.parse("https://runelite.net/atom.xml"); private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); + private final OkHttpClient okHttpClient; + private final HttpUrl rssUrl; + + @Autowired + public BlogService( + OkHttpClient okHttpClient, + @Value("${runelite.feed.rssUrl}") String rssUrl + ) + { + this.okHttpClient = okHttpClient; + this.rssUrl = HttpUrl.get(rssUrl); + } + public List getBlogPosts() throws IOException { Request request = new Request.Builder() - .url(RSS_URL) + .url(rssUrl) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { diff --git a/http-service/src/main/java/net/runelite/http/service/feed/osrsnews/OSRSNewsService.java b/http-service/src/main/java/net/runelite/http/service/feed/osrsnews/OSRSNewsService.java index 0ae08bc85c..e53b2d8044 100644 --- a/http-service/src/main/java/net/runelite/http/service/feed/osrsnews/OSRSNewsService.java +++ b/http-service/src/main/java/net/runelite/http/service/feed/osrsnews/OSRSNewsService.java @@ -33,13 +33,15 @@ import java.util.List; import java.util.Locale; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.feed.FeedItem; import net.runelite.http.api.feed.FeedItemType; import net.runelite.http.service.util.exception.InternalServerErrorException; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -50,16 +52,28 @@ import org.xml.sax.SAXException; @Service public class OSRSNewsService { - private static final HttpUrl RSS_URL = HttpUrl.parse("https://services.runescape.com/m=news/latest_news.rss?oldschool=true"); private static final SimpleDateFormat PUB_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy '00:00:00 GMT'", Locale.US); + private final OkHttpClient okHttpClient; + private final HttpUrl rssUrl; + + @Autowired + public OSRSNewsService( + OkHttpClient okHttpClient, + @Value("${runelite.osrsnews.rssUrl}") String rssUrl + ) + { + this.okHttpClient = okHttpClient; + this.rssUrl = HttpUrl.get(rssUrl); + } + public List getNews() throws IOException { Request request = new Request.Builder() - .url(RSS_URL) + .url(rssUrl) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { diff --git a/http-service/src/main/java/net/runelite/http/service/feed/twitter/TwitterService.java b/http-service/src/main/java/net/runelite/http/service/feed/twitter/TwitterService.java index 5bab4300a3..4b7b026646 100644 --- a/http-service/src/main/java/net/runelite/http/service/feed/twitter/TwitterService.java +++ b/http-service/src/main/java/net/runelite/http/service/feed/twitter/TwitterService.java @@ -39,6 +39,7 @@ import net.runelite.http.api.feed.FeedItemType; import net.runelite.http.service.util.exception.InternalServerErrorException; import okhttp3.FormBody; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.springframework.beans.factory.annotation.Autowired; @@ -54,6 +55,7 @@ public class TwitterService private final String credentials; private final String listId; + private final OkHttpClient okHttpClient; private String token; @@ -61,11 +63,13 @@ public class TwitterService public TwitterService( @Value("${runelite.twitter.consumerkey}") String consumerKey, @Value("${runelite.twitter.secretkey}") String consumerSecret, - @Value("${runelite.twitter.listid}") String listId + @Value("${runelite.twitter.listid}") String listId, + OkHttpClient okHttpClient ) { this.credentials = consumerKey + ":" + consumerSecret; this.listId = listId; + this.okHttpClient = okHttpClient; } public List getTweets() throws IOException @@ -91,7 +95,7 @@ public class TwitterService .header("Authorization", "Bearer " + token) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -143,7 +147,7 @@ public class TwitterService .post(new FormBody.Builder().add("grant_type", "client_credentials").build()) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { diff --git a/http-service/src/main/java/net/runelite/http/service/item/ItemService.java b/http-service/src/main/java/net/runelite/http/service/item/ItemService.java index d25621260e..bc3f03e70c 100644 --- a/http-service/src/main/java/net/runelite/http/service/item/ItemService.java +++ b/http-service/src/main/java/net/runelite/http/service/item/ItemService.java @@ -39,10 +39,12 @@ import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.item.ItemType; import net.runelite.http.service.cache.CacheService; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.sql2o.Connection; @@ -53,10 +55,6 @@ import org.sql2o.Sql2o; @Slf4j public class ItemService { - private static final String BASE = "https://services.runescape.com/m=itemdb_oldschool"; - private static final HttpUrl RS_ITEM_URL = HttpUrl.parse(BASE + "/api/catalogue/detail.json"); - private static final HttpUrl RS_PRICE_URL = HttpUrl.parse(BASE + "/api/graph"); - private static final String CREATE_ITEMS = "CREATE TABLE IF NOT EXISTS `items` (\n" + " `id` int(11) NOT NULL,\n" + " `name` tinytext NOT NULL,\n" @@ -77,16 +75,27 @@ public class ItemService private final Sql2o sql2o; private final CacheService cacheService; + private final OkHttpClient okHttpClient; + private final HttpUrl itemUrl; + private final HttpUrl priceUrl; private int[] tradeableItems; private final Random random = new Random(); @Autowired - public ItemService(@Qualifier("Runelite SQL2O") Sql2o sql2o, - CacheService cacheService) + public ItemService( + @Qualifier("Runelite SQL2O") Sql2o sql2o, + CacheService cacheService, + OkHttpClient okHttpClient, + @Value("${runelite.item.itemUrl}") String itemUrl, + @Value("${runelite.item.priceUrl}") String priceUrl + ) { this.sql2o = sql2o; this.cacheService = cacheService; + this.okHttpClient = okHttpClient; + this.itemUrl = HttpUrl.get(itemUrl); + this.priceUrl = HttpUrl.get(priceUrl); try (Connection con = sql2o.open()) { @@ -195,7 +204,7 @@ public class ItemService private RSItem fetchRSItem(int itemId) throws IOException { - HttpUrl itemUrl = RS_ITEM_URL + HttpUrl itemUrl = this.itemUrl .newBuilder() .addQueryParameter("item", "" + itemId) .build(); @@ -211,7 +220,7 @@ public class ItemService private RSPrices fetchRSPrices(int itemId) throws IOException { - HttpUrl priceUrl = RS_PRICE_URL + HttpUrl priceUrl = this.priceUrl .newBuilder() .addPathSegment(itemId + ".json") .build(); @@ -223,9 +232,9 @@ public class ItemService return fetchJson(request, RSPrices.class); } - private static T fetchJson(Request request, Class clazz) throws IOException + private T fetchJson(Request request, Class clazz) throws IOException { - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { diff --git a/http-service/src/main/java/net/runelite/http/service/wiki/WikiPriceService.java b/http-service/src/main/java/net/runelite/http/service/wiki/WikiPriceService.java index 3167767836..2e32fc1808 100644 --- a/http-service/src/main/java/net/runelite/http/service/wiki/WikiPriceService.java +++ b/http-service/src/main/java/net/runelite/http/service/wiki/WikiPriceService.java @@ -31,6 +31,7 @@ import java.util.Map; import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.springframework.beans.factory.annotation.Autowired; @@ -57,14 +58,19 @@ public class WikiPriceService ") ENGINE=InnoDB;"; private final Sql2o sql2o; - - @Value("${runelite.wiki.url}") - private String url; + private final OkHttpClient okHttpClient; + private final HttpUrl wikiUrl; @Autowired - public WikiPriceService(@Qualifier("Runelite SQL2O") Sql2o sql2o) + public WikiPriceService( + @Qualifier("Runelite SQL2O") Sql2o sql2o, + OkHttpClient okHttpClient, + @Value("${runelite.wiki.url}") String url + ) { this.sql2o = sql2o; + this.okHttpClient = okHttpClient; + this.wikiUrl = HttpUrl.get(url); try (Connection con = sql2o.open()) { @@ -112,13 +118,12 @@ public class WikiPriceService private PriceResult getPrices() throws IOException { - HttpUrl httpUrl = HttpUrl.parse(url); Request request = new Request.Builder() - .url(httpUrl) + .url(wikiUrl) .header("User-Agent", "RuneLite") .build(); - try (Response responseOk = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response responseOk = okHttpClient.newCall(request).execute()) { if (!responseOk.isSuccessful()) { diff --git a/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java b/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java index fe85fb35dd..1f8debe7eb 100644 --- a/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java +++ b/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java @@ -29,21 +29,32 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldResult; import net.runelite.http.api.worlds.WorldType; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service public class WorldsService { - private static final HttpUrl WORLD_URL = HttpUrl.parse("http://www.runescape.com/g=oldscape/slr.ws?order=LPWM"); + private final OkHttpClient okHttpClient; + private final HttpUrl url; - private HttpUrl url = WORLD_URL; + @Autowired + public WorldsService( + OkHttpClient okHttpClient, + @Value("${runelite.worlds.url}") String url + ) + { + this.okHttpClient = okHttpClient; + this.url = HttpUrl.get(url); + } public WorldResult getWorlds() throws IOException { @@ -53,7 +64,7 @@ public class WorldsService byte[] b; - try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) + try (Response okresponse = okHttpClient.newCall(okrequest).execute()) { b = okresponse.body().bytes(); } @@ -118,14 +129,4 @@ public class WorldsService return sb.toString(); } - - public HttpUrl getUrl() - { - return url; - } - - public void setUrl(HttpUrl url) - { - this.url = url; - } } diff --git a/http-service/src/main/resources/application.yaml b/http-service/src/main/resources/application.yaml index 9eedd33c01..f77e17ae19 100644 --- a/http-service/src/main/resources/application.yaml +++ b/http-service/src/main/resources/application.yaml @@ -47,3 +47,12 @@ runelite: url: https://prices.runescape.wiki/api/v1/osrs/latest price: cache: 30 # minutes + feed: + rssUrl: https://runelite.net/atom.xml + worlds: + url: http://www.runescape.com/g=oldscape/slr.ws?order=LPWM + osrsnews: + rssUrl: https://services.runescape.com/m=news/latest_news.rss?oldschool=true + item: + itemUrl: https://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json + priceUrl: https://services.runescape.com/m=itemdb_oldschool/api/graph \ No newline at end of file diff --git a/http-service/src/test/java/net/runelite/http/service/worlds/WorldsServiceTest.java b/http-service/src/test/java/net/runelite/http/service/worlds/WorldsServiceTest.java index 6d55fc52aa..b6275d7c48 100644 --- a/http-service/src/test/java/net/runelite/http/service/worlds/WorldsServiceTest.java +++ b/http-service/src/test/java/net/runelite/http/service/worlds/WorldsServiceTest.java @@ -29,6 +29,7 @@ import java.io.InputStream; import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldResult; import net.runelite.http.api.worlds.WorldType; +import okhttp3.OkHttpClient; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; @@ -60,8 +61,7 @@ public class WorldsServiceTest @Test public void testListWorlds() throws Exception { - WorldsService worlds = new WorldsService(); - worlds.setUrl(server.url("/")); + WorldsService worlds = new WorldsService(new OkHttpClient(), server.url("/").toString()); WorldResult worldResult = worlds.getWorlds(); assertEquals(82, worldResult.getWorlds().size()); From 9349ea84bbd9429e62b1162fa41e7bd7faea3196 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 22 Dec 2021 15:46:18 -0500 Subject: [PATCH 11/17] cache: remove http-api dependency This was only for the xtea client, which we don't use anymore anyway. Instead allow XteaKeyManager to read from an input stream. --- cache/pom.xml | 6 ---- .../runelite/cache/region/RegionLoader.java | 1 - .../java/net/runelite/cache/util/XteaKey.java | 34 +++++++++++++++++++ .../runelite/cache/util/XteaKeyManager.java | 30 +++++++--------- .../net/runelite/cache/MapDumperTest.java | 2 -- 5 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 cache/src/main/java/net/runelite/cache/util/XteaKey.java diff --git a/cache/pom.xml b/cache/pom.xml index 8ed326415b..4b42efcf78 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -42,12 +42,6 @@ - - net.runelite - http-api - ${project.version} - - com.google.guava guava diff --git a/cache/src/main/java/net/runelite/cache/region/RegionLoader.java b/cache/src/main/java/net/runelite/cache/region/RegionLoader.java index a15e25a868..21f4868a9a 100644 --- a/cache/src/main/java/net/runelite/cache/region/RegionLoader.java +++ b/cache/src/main/java/net/runelite/cache/region/RegionLoader.java @@ -60,7 +60,6 @@ public class RegionLoader this.store = store; index = store.getIndex(IndexType.MAPS); keyManager = new XteaKeyManager(); - keyManager.loadKeys(); } public void loadRegions() throws IOException diff --git a/cache/src/main/java/net/runelite/cache/util/XteaKey.java b/cache/src/main/java/net/runelite/cache/util/XteaKey.java new file mode 100644 index 0000000000..888c6e7eeb --- /dev/null +++ b/cache/src/main/java/net/runelite/cache/util/XteaKey.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021, Adam + * 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.cache.util; + +import lombok.Data; + +@Data +public class XteaKey +{ + private int region; + private int keys[]; +} diff --git a/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java b/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java index 38ba347d4b..c1c7607e9b 100644 --- a/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java +++ b/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java @@ -24,12 +24,14 @@ */ package net.runelite.cache.util; -import java.io.IOException; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.List; import java.util.Map; -import net.runelite.http.api.RuneLiteAPI; -import net.runelite.http.api.xtea.XteaClient; -import net.runelite.http.api.xtea.XteaKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,22 +41,16 @@ public class XteaKeyManager private final Map keys = new HashMap<>(); - public void loadKeys() + public void loadKeys(InputStream in) { - XteaClient xteaClient = new XteaClient(RuneLiteAPI.CLIENT); + // CHECKSTYLE:OFF + List k = new Gson() + .fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), new TypeToken>() { }.getType()); + // CHECKSTYLE:ON - try + for (XteaKey key : k) { - for (XteaKey key : xteaClient.get()) - { - keys.put(key.getRegion(), key.getKeys()); - } - } - catch (IOException ex) - { - // happens on release when it is not deployed yet - logger.debug("unable to load xtea keys", ex); - return; + keys.put(key.getRegion(), key.getKeys()); } logger.info("Loaded {} keys", keys.size()); diff --git a/cache/src/test/java/net/runelite/cache/MapDumperTest.java b/cache/src/test/java/net/runelite/cache/MapDumperTest.java index 8d1fffd7cb..b73c250e43 100644 --- a/cache/src/test/java/net/runelite/cache/MapDumperTest.java +++ b/cache/src/test/java/net/runelite/cache/MapDumperTest.java @@ -65,7 +65,6 @@ public class MapDumperTest File base = StoreLocation.LOCATION, outDir = folder.newFolder(); XteaKeyManager keyManager = new XteaKeyManager(); - keyManager.loadKeys(); try (Store store = new Store(base)) { @@ -121,7 +120,6 @@ public class MapDumperTest Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.MAPS); XteaKeyManager keyManager = new XteaKeyManager(); - keyManager.loadKeys(); for (int i = 0; i < MAX_REGIONS; ++i) { From ab07c09d76bba850239f3c8e223761eef05b60ce Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 22 Dec 2021 15:49:43 -0500 Subject: [PATCH 12/17] http-api: lombokize a few classes --- .../http/api/account/OAuthResponse.java | 22 ++---------------- .../http/api/ws/messages/Handshake.java | 12 ++-------- .../http/api/ws/messages/LoginResponse.java | 19 ++------------- .../net/runelite/http/api/xtea/XteaKey.java | 23 +++---------------- .../runelite/http/api/xtea/XteaRequest.java | 17 ++------------ 5 files changed, 11 insertions(+), 82 deletions(-) diff --git a/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java b/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java index dc9d3c34ad..930540b6eb 100644 --- a/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java +++ b/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java @@ -25,29 +25,11 @@ package net.runelite.http.api.account; import java.util.UUID; +import lombok.Data; +@Data public class OAuthResponse { private String oauthUrl; private UUID uid; - - public String getOauthUrl() - { - return oauthUrl; - } - - public void setOauthUrl(String oauthUrl) - { - this.oauthUrl = oauthUrl; - } - - public UUID getUid() - { - return uid; - } - - public void setUid(UUID uid) - { - this.uid = uid; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java b/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java index 557f8f524b..5320c95ab5 100644 --- a/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java +++ b/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java @@ -25,19 +25,11 @@ package net.runelite.http.api.ws.messages; import java.util.UUID; +import lombok.Data; import net.runelite.http.api.ws.WebsocketMessage; +@Data public class Handshake extends WebsocketMessage { private UUID session; - - public UUID getSession() - { - return session; - } - - public void setSession(UUID session) - { - this.session = session; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java b/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java index b517e773a2..8f22db8f80 100644 --- a/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java +++ b/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java @@ -24,29 +24,14 @@ */ package net.runelite.http.api.ws.messages; +import lombok.Data; import net.runelite.http.api.ws.WebsocketMessage; /** * Called after a successful login to the server - * @author Adam */ +@Data public class LoginResponse extends WebsocketMessage { private String username; - - public String getUsername() - { - return username; - } - - public void setUsername(String username) - { - this.username = username; - } - - @Override - public String toString() - { - return "LoginResponse{" + "username=" + username + '}'; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java index c108f223cb..bed2a017f1 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java @@ -24,28 +24,11 @@ */ package net.runelite.http.api.xtea; +import lombok.Data; + +@Data public class XteaKey { private int region; private int keys[]; - - public int getRegion() - { - return region; - } - - public void setRegion(int region) - { - this.region = region; - } - - public int[] getKeys() - { - return keys; - } - - public void setKeys(int[] keys) - { - this.keys = keys; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java index f84c85b83b..fdce607f59 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java @@ -26,27 +26,14 @@ package net.runelite.http.api.xtea; import java.util.ArrayList; import java.util.List; +import lombok.Data; +@Data public class XteaRequest { private int revision; private List keys = new ArrayList<>(); - public int getRevision() - { - return revision; - } - - public void setRevision(int revision) - { - this.revision = revision; - } - - public List getKeys() - { - return keys; - } - public void addKey(XteaKey key) { keys.add(key); From cc32ba3112e2f8dfbf93b03609fbfa1df53ddc7f Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Thu, 23 Dec 2021 03:22:21 +0100 Subject: [PATCH 13/17] project: Mixins fix RL MenuAction types --- .../src/main/java/net/runelite/mixins/RSClientMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 556bcbf8f0..4b616f6ef7 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -2063,7 +2063,7 @@ public abstract class RSClientMixin implements RSClient if (len > 0) { int type = getMenuOpcodes()[len - 1]; - return type == MenuAction.RUNELITE_OVERLAY.getId(); + return type == MenuAction.RUNELITE_OVERLAY.getId() || type == MenuAction.RUNELITE_OVERLAY_CONFIG.getId() || type == MenuAction.RUNELITE_INFOBOX.getId(); } return false; From 9914ca8058dc93802c9dbeea86290e253450d89a Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Thu, 23 Dec 2021 04:37:11 +0100 Subject: [PATCH 14/17] project: checkstyle --- .../main/java/net/runelite/client/config/ConfigManager.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index cb483c9727..37ab9c7c99 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -27,7 +27,6 @@ package net.runelite.client.config; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableSet; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; import com.google.gson.Gson; @@ -78,11 +77,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.Nullable; import javax.inject.Inject; From 5aa031c8cc5f5038859c99fdf99591e0421d0edf Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Thu, 23 Dec 2021 04:37:58 +0100 Subject: [PATCH 15/17] project: copy --- .../java/net/runelite/mixins/RSClientMixin.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 4b616f6ef7..7b0f467818 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -149,6 +149,7 @@ import net.runelite.rs.api.RSEvictingDualNodeHashTable; import net.runelite.rs.api.RSFriendSystem; import net.runelite.rs.api.RSIndexedSprite; import net.runelite.rs.api.RSInterfaceParent; +import net.runelite.rs.api.RSItemComposition; import net.runelite.rs.api.RSItemContainer; import net.runelite.rs.api.RSModelData; import net.runelite.rs.api.RSNPC; @@ -1760,18 +1761,15 @@ public abstract class RSClientMixin implements RSClient client.getCallbacks().post(chatMessage); } - @Inject - @MethodHook("draw") - public void draw(boolean var1) + @Copy("draw") + @Replace("draw") + public void copy$draw(boolean var1) { callbacks.frame(); updateCamera(); - } - @Inject - @MethodHook(value = "draw", end = true) - public void drawEnd(boolean var1) - { + copy$draw(var1); + checkResize(); } From 7403d9ca5c2f8a9e86689db754e95f44deea6be9 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Thu, 23 Dec 2021 04:38:37 +0100 Subject: [PATCH 16/17] project: ????????? --- .../java/net/runelite/mixins/RSItemCompositionMixin.java | 6 ++++++ .../java/net/runelite/mixins/RSObjectCompositionMixin.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java index 8662d5e513..f959656734 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java @@ -30,6 +30,12 @@ public abstract class RSItemCompositionMixin implements RSItemComposition cachedModels2.resize(1024); } + @Inject + RSItemCompositionMixin() + { + + } + @Inject @Override public boolean isStackable() diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java index 22f0037936..64dc949aba 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java @@ -25,6 +25,12 @@ public abstract class RSObjectCompositionMixin implements RSObjectComposition objectDefinitionModelsCache.resize(256); } + @Inject + RSObjectCompositionMixin() + { + + } + @Inject @Override public int getAccessBitMask() From 8710ed3ca44b6c5f21b37769995c17cb92544603 Mon Sep 17 00:00:00 2001 From: Owain van Brakel Date: Thu, 23 Dec 2021 04:38:58 +0100 Subject: [PATCH 17/17] project: catch game crash --- .../main/java/net/runelite/mixins/RSClientMixin.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 7b0f467818..548c8e015b 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -1730,6 +1730,18 @@ public abstract class RSClientMixin implements RSClient client.getScene().menuOpen(client.getPlane(), x - client.getViewportXOffset(), y - client.getViewportYOffset(), false); } + @Copy("addWidgetItemMenuItem") + @Replace("addWidgetItemMenuItem") + static void copy$addWidgetItemMenuItem(RSWidget var0, RSItemComposition var1, int var2, int var3, boolean var4) + { + String[] var5 = var1.getInventoryActions(); + + if (var5.length > var3) + { + copy$addWidgetItemMenuItem(var0, var1, var2, var3, var4); + } + } + @Inject @MethodHook("updateNpcs") public static void updateNpcs(boolean var0, RSPacketBuffer var1)