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.
This commit is contained in:
6
cache/pom.xml
vendored
6
cache/pom.xml
vendored
@@ -42,12 +42,6 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.runelite</groupId>
|
||||
<artifactId>http-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
||||
@@ -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
|
||||
|
||||
34
cache/src/main/java/net/runelite/cache/util/XteaKey.java
vendored
Normal file
34
cache/src/main/java/net/runelite/cache/util/XteaKey.java
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||
* 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[];
|
||||
}
|
||||
@@ -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<Integer, int[]> keys = new HashMap<>();
|
||||
|
||||
public void loadKeys()
|
||||
public void loadKeys(InputStream in)
|
||||
{
|
||||
XteaClient xteaClient = new XteaClient(RuneLiteAPI.CLIENT);
|
||||
// CHECKSTYLE:OFF
|
||||
List<XteaKey> k = new Gson()
|
||||
.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), new TypeToken<List<XteaKey>>() { }.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());
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user