From 7dd504fdf524afb6cbdc0d864a09f2dc7347e56a Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 20 Dec 2021 18:28:18 -0500 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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