From 670e62b6b9fd877d473b296d5d68a93930c0a222 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 6 Apr 2020 23:25:45 -0400 Subject: [PATCH] item service: remove old item searching and item lookup methods We haven't used this code in awhile. Additionally modify the price crawler to re-fetch known items in the event the name or examine changes. --- .../java/net/runelite/http/api/item/Item.java | 36 ---- .../runelite/http/api/item/ItemClient.java | 131 ------------ .../runelite/http/api/item/SearchResult.java | 42 ---- .../http/service/item/ItemController.java | 90 +-------- .../runelite/http/service/item/ItemEntry.java | 13 -- .../http/service/item/ItemService.java | 189 ++---------------- .../http/service/item/PendingLookup.java | 55 ----- .../runelite/http/service/item/RSItem.java | 16 +- .../http/service/item/RSItemResponse.java | 2 +- .../runelite/http/service/item/RSSearch.java | 34 ---- 10 files changed, 19 insertions(+), 589 deletions(-) delete mode 100644 http-api/src/main/java/net/runelite/http/api/item/Item.java delete mode 100644 http-api/src/main/java/net/runelite/http/api/item/SearchResult.java delete mode 100644 http-service/src/main/java/net/runelite/http/service/item/PendingLookup.java delete mode 100644 http-service/src/main/java/net/runelite/http/service/item/RSSearch.java diff --git a/http-api/src/main/java/net/runelite/http/api/item/Item.java b/http-api/src/main/java/net/runelite/http/api/item/Item.java deleted file mode 100644 index 3a6f0346c4..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/item/Item.java +++ /dev/null @@ -1,36 +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.item; - -import lombok.Data; - -@Data -public class Item -{ - private int id; - private String name; - private String description; - private ItemType type; -} diff --git a/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java b/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java index d1262e32c6..0dea2d1eed 100644 --- a/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java +++ b/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java @@ -26,14 +26,11 @@ package net.runelite.http.api.item; import com.google.gson.JsonParseException; import com.google.gson.reflect.TypeToken; -import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Type; -import java.util.Arrays; import java.util.Map; -import javax.imageio.ImageIO; import javax.inject.Inject; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; @@ -55,134 +52,6 @@ public class ItemClient this.client = client; } - public ItemPrice lookupItemPrice(int itemId) throws IOException - { - HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() - .addPathSegment("item") - .addPathSegment("" + itemId) - .addPathSegment("price") - .build(); - - logger.debug("Built URI: {}", url); - - Request request = new Request.Builder() - .url(url) - .build(); - - try (Response response = client.newCall(request).execute()) - { - if (!response.isSuccessful()) - { - logger.debug("Error looking up item {}: {}", itemId, response); - return null; - } - - InputStream in = response.body().byteStream(); - return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), ItemPrice.class); - } - catch (JsonParseException ex) - { - throw new IOException(ex); - } - } - - public ItemPrice[] lookupItemPrice(Integer[] itemIds) throws IOException - { - HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder() - .addPathSegment("item") - .addPathSegment("price"); - - for (int itemId : itemIds) - { - urlBuilder.addQueryParameter("id", String.valueOf(itemId)); - } - - HttpUrl url = urlBuilder.build(); - - logger.debug("Built URI: {}", url); - - Request request = new Request.Builder() - .url(url) - .build(); - - try (Response response = client.newCall(request).execute()) - { - if (!response.isSuccessful()) - { - logger.debug("Error looking up items {}: {}", Arrays.toString(itemIds), response); - return null; - } - - InputStream in = response.body().byteStream(); - return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), ItemPrice[].class); - } - catch (JsonParseException ex) - { - throw new IOException(ex); - } - } - - public BufferedImage getIcon(int itemId) throws IOException - { - HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() - .addPathSegment("item") - .addPathSegment("" + itemId) - .addPathSegment("icon") - .build(); - - logger.debug("Built URI: {}", url); - - Request request = new Request.Builder() - .url(url) - .build(); - - try (Response response = client.newCall(request).execute()) - { - if (!response.isSuccessful()) - { - logger.debug("Error grabbing icon {}: {}", itemId, response); - return null; - } - - InputStream in = response.body().byteStream(); - synchronized (ImageIO.class) - { - return ImageIO.read(in); - } - } - } - - public SearchResult search(String itemName) throws IOException - { - HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() - .addPathSegment("item") - .addPathSegment("search") - .addQueryParameter("query", itemName) - .build(); - - logger.debug("Built URI: {}", url); - - Request request = new Request.Builder() - .url(url) - .build(); - - try (Response response = client.newCall(request).execute()) - { - if (!response.isSuccessful()) - { - logger.debug("Error looking up item {}: {}", itemName, response); - return null; - } - - InputStream in = response.body().byteStream(); - return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), SearchResult.class); - } - catch (JsonParseException ex) - { - throw new IOException(ex); - } - } - public ItemPrice[] getPrices() throws IOException { HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder() diff --git a/http-api/src/main/java/net/runelite/http/api/item/SearchResult.java b/http-api/src/main/java/net/runelite/http/api/item/SearchResult.java deleted file mode 100644 index 90ae1ec783..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/item/SearchResult.java +++ /dev/null @@ -1,42 +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.item; - -import java.util.List; - -public class SearchResult -{ - private List items; - - public List getItems() - { - return items; - } - - public void setItems(List items) - { - this.items = items; - } -} diff --git a/http-service/src/main/java/net/runelite/http/service/item/ItemController.java b/http-service/src/main/java/net/runelite/http/service/item/ItemController.java index 8db56ef2ff..331f01db69 100644 --- a/http-service/src/main/java/net/runelite/http/service/item/ItemController.java +++ b/http-service/src/main/java/net/runelite/http/service/item/ItemController.java @@ -26,8 +26,6 @@ package net.runelite.http.service.item; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import com.google.common.hash.HashCode; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; @@ -35,11 +33,7 @@ import java.time.Instant; import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import javax.servlet.http.HttpServletResponse; -import net.runelite.http.api.item.Item; import net.runelite.http.api.item.ItemPrice; -import net.runelite.http.api.item.SearchResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.CacheControl; import org.springframework.http.ResponseEntity; @@ -53,7 +47,6 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/item") public class ItemController { - private static final String RUNELITE_CACHE = "RuneLite-Cache"; private static final int MAX_BATCH_LOOKUP = 1024; private static class MemoizedPrices @@ -75,10 +68,6 @@ public class ItemController } } - private final Cache cachedEmpty = CacheBuilder.newBuilder() - .maximumSize(1024L) - .build(); - private final ItemService itemService; private final Supplier memoizedPrices; @@ -101,58 +90,12 @@ public class ItemController .toArray(ItemPrice[]::new)), 30, TimeUnit.MINUTES); } - @GetMapping("/{itemId}") - public Item getItem(HttpServletResponse response, @PathVariable int itemId) - { - ItemEntry item = itemService.getItem(itemId); - if (item != null) - { - return item.toItem(); - } - - itemService.queueItem(itemId); - return null; - } - - @GetMapping(path = "/{itemId}/icon", produces = "image/gif") - public ResponseEntity getIcon(@PathVariable int itemId) - { - ItemEntry item = itemService.getItem(itemId); - if (item != null && item.getIcon() != null) - { - return ResponseEntity.ok(item.getIcon()); - } - - itemService.queueItem(itemId); - return ResponseEntity.notFound().build(); - } - - @GetMapping(path = "/{itemId}/icon/large", produces = "image/gif") - public ResponseEntity getIconLarge(HttpServletResponse response, @PathVariable int itemId) - { - ItemEntry item = itemService.getItem(itemId); - if (item != null && item.getIcon_large() != null) - { - return ResponseEntity.ok(item.getIcon_large()); - } - - itemService.queueItem(itemId); - return ResponseEntity.notFound().build(); - } - @GetMapping("/{itemId}/price") public ResponseEntity itemPrice( @PathVariable int itemId, @RequestParam(required = false) Instant time ) { - if (cachedEmpty.getIfPresent(itemId) != null) - { - return ResponseEntity.notFound() - .header(RUNELITE_CACHE, "HIT") - .build(); - } - Instant now = Instant.now(); if (time != null && time.isAfter(now)) @@ -160,16 +103,6 @@ public class ItemController time = now; } - ItemEntry item = itemService.getItem(itemId); - if (item == null) - { - itemService.queueItem(itemId); // queue lookup - cachedEmpty.put(itemId, itemId); // cache empty - return ResponseEntity.notFound() - .header(RUNELITE_CACHE, "MISS") - .build(); - } - PriceEntry priceEntry = itemService.getPrice(itemId, time); if (time != null) @@ -178,22 +111,21 @@ public class ItemController { // we maybe can't backfill this return ResponseEntity.notFound() - .header(RUNELITE_CACHE, "MISS") + .cacheControl(CacheControl.maxAge(30, TimeUnit.MINUTES).cachePublic()) .build(); } } else if (priceEntry == null) { // Price is unknown - cachedEmpty.put(itemId, itemId); return ResponseEntity.notFound() - .header(RUNELITE_CACHE, "MISS") + .cacheControl(CacheControl.maxAge(30, TimeUnit.MINUTES).cachePublic()) .build(); } ItemPrice itemPrice = new ItemPrice(); - itemPrice.setId(item.getId()); - itemPrice.setName(item.getName()); + itemPrice.setId(itemId); + itemPrice.setName(priceEntry.getName()); itemPrice.setPrice(priceEntry.getPrice()); itemPrice.setTime(priceEntry.getTime()); @@ -202,20 +134,6 @@ public class ItemController .body(itemPrice); } - @GetMapping("/search") - public SearchResult search(@RequestParam String query) - { - List result = itemService.search(query); - - itemService.queueSearch(query); - - SearchResult searchResult = new SearchResult(); - searchResult.setItems(result.stream() - .map(ItemEntry::toItem) - .collect(Collectors.toList())); - return searchResult; - } - @GetMapping("/price") public ItemPrice[] prices(@RequestParam("id") int[] itemIds) { diff --git a/http-service/src/main/java/net/runelite/http/service/item/ItemEntry.java b/http-service/src/main/java/net/runelite/http/service/item/ItemEntry.java index b92f171cc7..41186b1608 100644 --- a/http-service/src/main/java/net/runelite/http/service/item/ItemEntry.java +++ b/http-service/src/main/java/net/runelite/http/service/item/ItemEntry.java @@ -26,7 +26,6 @@ package net.runelite.http.service.item; import java.time.Instant; import lombok.Data; -import net.runelite.http.api.item.Item; import net.runelite.http.api.item.ItemType; @Data @@ -36,17 +35,5 @@ public class ItemEntry private String name; private String description; private ItemType type; - private byte[] icon; - private byte[] icon_large; private Instant timestamp; - - public Item toItem() - { - Item item = new Item(); - item.setId(id); - item.setName(name); - item.setDescription(description); - item.setType(type); - return item; - } } 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 72a0fe85aa..35aaabe94a 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 @@ -35,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.concurrent.ConcurrentLinkedQueue; import lombok.extern.slf4j.Slf4j; import net.runelite.cache.definitions.ItemDefinition; import net.runelite.http.api.RuneLiteAPI; @@ -59,18 +58,14 @@ 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 HttpUrl RS_SEARCH_URL = HttpUrl.parse(BASE + "/api/catalogue/items.json?category=1"); private static final String CREATE_ITEMS = "CREATE TABLE IF NOT EXISTS `items` (\n" + " `id` int(11) NOT NULL,\n" + " `name` tinytext NOT NULL,\n" + " `description` tinytext NOT NULL,\n" + " `type` enum('DEFAULT') NOT NULL,\n" - + " `icon` blob,\n" - + " `icon_large` blob,\n" + " `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n" - + " PRIMARY KEY (`id`),\n" - + " FULLTEXT idx_name (name)\n" + + " PRIMARY KEY (`id`)\n" + ") ENGINE=InnoDB"; private static final String CREATE_PRICES = "CREATE TABLE IF NOT EXISTS `prices` (\n" @@ -82,12 +77,9 @@ public class ItemService + " KEY `item_fetched_time` (`item`,`fetched_time`)\n" + ") ENGINE=InnoDB"; - private static final int MAX_PENDING = 512; - private final Sql2o sql2o; private final CacheService cacheService; - private final ConcurrentLinkedQueue pendingLookups = new ConcurrentLinkedQueue(); private int[] tradeableItems; private final Random random = new Random(); @@ -112,11 +104,9 @@ public class ItemService { try (Connection con = sql2o.open()) { - ItemEntry item = con.createQuery("select id, name, description, type, icon, icon_large from items where id = :id") + return con.createQuery("select id, name, description, type from items where id = :id") .addParameter("id", itemId) .executeAndFetchFirst(ItemEntry.class); - - return item; } } @@ -174,54 +164,21 @@ public class ItemService } } - public List search(String search) - { - try (Connection con = sql2o.open()) - { - return con.createQuery("select id, name, description, type, match (name) against (:search) as score from items " - + "where match (name) against (:search) order by score desc limit 10") - .throwOnMappingFailure(false) // otherwise it tries to map 'score' - .addParameter("search", search) - .executeAndFetch(ItemEntry.class); - } - } - public ItemEntry fetchItem(int itemId) { try { RSItem rsItem = fetchRSItem(itemId); - byte[] icon = null, iconLarge = null; - - try - { - icon = fetchImage(rsItem.getIcon()); - } - catch (IOException ex) - { - log.warn("error fetching image", ex); - } - - try - { - iconLarge = fetchImage(rsItem.getIcon_large()); - } - catch (IOException ex) - { - log.warn("error fetching image", ex); - } try (Connection con = sql2o.open()) { - con.createQuery("insert into items (id, name, description, type, icon, icon_large) values (:id," - + " :name, :description, :type, :icon, :icon_large) ON DUPLICATE KEY UPDATE name = :name," - + " description = :description, type = :type, icon = :icon, icon_large = :icon_large") + con.createQuery("insert into items (id, name, description, type) values (:id," + + " :name, :description, :type) ON DUPLICATE KEY UPDATE name = :name," + + " description = :description, type = :type") .addParameter("id", rsItem.getId()) .addParameter("name", rsItem.getName()) .addParameter("description", rsItem.getDescription()) .addParameter("type", rsItem.getType()) - .addParameter("icon", icon) - .addParameter("icon_large", iconLarge) .executeUpdate(); } @@ -230,8 +187,6 @@ public class ItemService item.setName(rsItem.getName()); item.setDescription(rsItem.getDescription()); item.setType(ItemType.of(rsItem.getType())); - item.setIcon(icon); - item.setIcon_large(iconLarge); return item; } catch (IOException ex) @@ -241,7 +196,7 @@ public class ItemService } } - public List fetchPrice(int itemId) + private List fetchPrice(int itemId) { RSPrices rsprice; try @@ -296,8 +251,8 @@ public class ItemService try (Connection con = sql2o.beginTransaction()) { Query query = con.createQuery("select t2.item, t3.name, t2.time, prices.price, prices.fetched_time from (select t1.item as item, max(t1.time) as time from prices t1 group by item) t2 " + - " join prices on t2.item=prices.item and t2.time=prices.time" + - " join items t3 on t2.item=t3.id"); + " join prices on t2.item=prices.item and t2.time=prices.time" + + " join items t3 on t2.item=t3.id"); return query.executeAndFetch(PriceEntry.class); } } @@ -332,46 +287,7 @@ public class ItemService return fetchJson(request, RSPrices.class); } - public RSSearch fetchRSSearch(String query) throws IOException - { - // rs api seems to require lowercase - query = query.toLowerCase(); - - HttpUrl searchUrl = RS_SEARCH_URL - .newBuilder() - .addQueryParameter("alpha", query) - .build(); - - Request request = new Request.Builder() - .url(searchUrl) - .build(); - - return fetchJson(request, RSSearch.class); - } - - private void batchInsertItems(RSSearch search) - { - try (Connection con = sql2o.beginTransaction()) - { - Query q = con.createQuery("insert into items (id, name, description, type) values (:id," - + " :name, :description, :type) ON DUPLICATE KEY UPDATE name = :name," - + " description = :description, type = :type"); - - for (RSItem rsItem : search.getItems()) - { - q.addParameter("id", rsItem.getId()) - .addParameter("name", rsItem.getName()) - .addParameter("description", rsItem.getDescription()) - .addParameter("type", rsItem.getType()) - .addToBatch(); - } - - q.executeBatch(); - con.commit(false); - } - } - - private T fetchJson(Request request, Class clazz) throws IOException + private static T fetchJson(Request request, Class clazz) throws IOException { try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) { @@ -389,78 +305,6 @@ public class ItemService } } - private byte[] fetchImage(String url) throws IOException - { - HttpUrl httpUrl = HttpUrl.parse(url); - - Request request = new Request.Builder() - .url(httpUrl) - .build(); - - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) - { - if (!response.isSuccessful()) - { - throw new IOException("Unsuccessful http response: " + response); - } - - return response.body().bytes(); - } - } - - public void queueSearch(String search) - { - if (pendingLookups.size() < MAX_PENDING) - { - pendingLookups.add(new PendingLookup(search, PendingLookup.Type.SEARCH)); - } - else - { - log.debug("Dropping pending search for {}", search); - } - } - - public void queueItem(int itemId) - { - if (pendingLookups.size() < MAX_PENDING) - { - pendingLookups.add(new PendingLookup(itemId, PendingLookup.Type.ITEM)); - } - else - { - log.debug("Dropping pending item lookup for {}", itemId); - } - } - - @Scheduled(fixedDelay = 5000) - public void check() - { - PendingLookup pendingLookup = pendingLookups.poll(); - if (pendingLookup == null) - { - return; - } - - switch (pendingLookup.getType()) - { - case SEARCH: - try - { - RSSearch reSearch = fetchRSSearch(pendingLookup.getSearch()); - - batchInsertItems(reSearch); - } - catch (IOException ex) - { - log.warn("error while searching items", ex); - } - break; - case ITEM: - fetchItem(pendingLookup.getItemId()); - break; - } - } - @Scheduled(fixedDelay = 20_000) public void crawlPrices() { @@ -472,16 +316,10 @@ public class ItemService int idx = random.nextInt(tradeableItems.length); int id = tradeableItems[idx]; - if (getItem(id) == null) - { - // This is a new item.. - log.debug("Fetching new item {}", id); - queueItem(id); - return; - } - log.debug("Fetching price for {}", id); + // check if the item name or description has changed + fetchItem(id); fetchPrice(id); } @@ -495,11 +333,10 @@ public class ItemService } tradeableItems = items.stream() - .filter(item -> item.isTradeable) - .mapToInt(item -> item.id) + .filter(ItemDefinition::isTradeable) + .mapToInt(ItemDefinition::getId) .toArray(); log.debug("Loaded {} tradeable items", tradeableItems.length); } - } diff --git a/http-service/src/main/java/net/runelite/http/service/item/PendingLookup.java b/http-service/src/main/java/net/runelite/http/service/item/PendingLookup.java deleted file mode 100644 index d23ff5c1d9..0000000000 --- a/http-service/src/main/java/net/runelite/http/service/item/PendingLookup.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018, 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.item; - -import lombok.Value; - -@Value -class PendingLookup -{ - enum Type - { - SEARCH, - ITEM; - } - - private final int itemId; - private final String search; - private final Type type; - - public PendingLookup(int itemId, Type type) - { - this.itemId = itemId; - this.search = null; - this.type = type; - } - - public PendingLookup(String search, Type type) - { - this.itemId = -1; - this.search = search; - this.type = type; - } -} diff --git a/http-service/src/main/java/net/runelite/http/service/item/RSItem.java b/http-service/src/main/java/net/runelite/http/service/item/RSItem.java index b7c09260c6..17e3352f6d 100644 --- a/http-service/src/main/java/net/runelite/http/service/item/RSItem.java +++ b/http-service/src/main/java/net/runelite/http/service/item/RSItem.java @@ -25,26 +25,12 @@ package net.runelite.http.service.item; import lombok.Data; -import net.runelite.http.api.item.Item; -import net.runelite.http.api.item.ItemType; @Data -public class RSItem +class RSItem { private int id; private String name; private String description; private String type; - private String icon; - private String icon_large; - - public Item toItem() - { - Item item = new Item(); - item.setId(id); - item.setName(name); - item.setType(ItemType.of(type)); - item.setDescription(description); - return item; - } } diff --git a/http-service/src/main/java/net/runelite/http/service/item/RSItemResponse.java b/http-service/src/main/java/net/runelite/http/service/item/RSItemResponse.java index 3fd7b3cef3..c0305cd552 100644 --- a/http-service/src/main/java/net/runelite/http/service/item/RSItemResponse.java +++ b/http-service/src/main/java/net/runelite/http/service/item/RSItemResponse.java @@ -27,7 +27,7 @@ package net.runelite.http.service.item; import lombok.Data; @Data -public class RSItemResponse +class RSItemResponse { private RSItem item; } diff --git a/http-service/src/main/java/net/runelite/http/service/item/RSSearch.java b/http-service/src/main/java/net/runelite/http/service/item/RSSearch.java deleted file mode 100644 index b0edfdf798..0000000000 --- a/http-service/src/main/java/net/runelite/http/service/item/RSSearch.java +++ /dev/null @@ -1,34 +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.item; - -import java.util.List; -import lombok.Data; - -@Data -public class RSSearch -{ - private List items; -}