From b6e17cd15e74fa3ad96eb181618b7924ca127a60 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 22 Dec 2021 12:46:52 -0500 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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);