Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
|
||||
object ProjectVersions {
|
||||
const val launcherVersion = "2.2.0"
|
||||
const val rlVersion = "1.6.21"
|
||||
const val rlVersion = "1.6.22"
|
||||
|
||||
const val openosrsVersion = "3.3.9"
|
||||
const val openosrsVersion = "3.4.0"
|
||||
|
||||
const val rsversion = 190
|
||||
const val cacheversion = 165
|
||||
|
||||
Vendored
+1
@@ -42,6 +42,7 @@ dependencies {
|
||||
implementation(group = "com.google.guava", name = "guava", version = "29.0-jre")
|
||||
implementation(group = "commons-cli", name = "commons-cli", version = "1.4")
|
||||
implementation(group = "io.netty", name = "netty-buffer", version = "4.1.50.Final")
|
||||
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.7.2")
|
||||
implementation(group = "org.antlr", name = "antlr4-runtime", version = "4.8-1")
|
||||
implementation(group = "org.apache.commons", name = "commons-compress", version = "1.20")
|
||||
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30")
|
||||
|
||||
+9
-9
@@ -31,13 +31,13 @@ public class HealthBarDefinition
|
||||
{
|
||||
public int id;
|
||||
public int field3276;
|
||||
public int field3277;
|
||||
public int field3278;
|
||||
public int field3283;
|
||||
public int field3272;
|
||||
public int field3275;
|
||||
public int healthBarFrontSpriteId;
|
||||
public int healthBarBackSpriteId;
|
||||
public int healthScale;
|
||||
public int healthBarPadding;
|
||||
public int field3277 = 255;
|
||||
public int field3278 = 255;
|
||||
public int field3283 = -1;
|
||||
public int field3272 = 1;
|
||||
public int field3275 = 70;
|
||||
public int healthBarFrontSpriteId = -1;
|
||||
public int healthBarBackSpriteId = -1;
|
||||
public int healthScale = 30;
|
||||
public int healthBarPadding = 0;
|
||||
}
|
||||
|
||||
@@ -98,9 +98,10 @@ public class RegionLoader
|
||||
Region region = new Region(i);
|
||||
region.loadTerrain(mapDef);
|
||||
|
||||
int[] keys = keyManager.getKeys(i);
|
||||
if (keys != null)
|
||||
Integer[] keysTmp = keyManager.getKeys(i);
|
||||
if (keysTmp != null)
|
||||
{
|
||||
int[] keys = {keysTmp[0], keysTmp[1], keysTmp[2], keysTmp[3]};
|
||||
try
|
||||
{
|
||||
data = land.decompress(storage.loadArchive(land), keys);
|
||||
|
||||
@@ -24,8 +24,11 @@
|
||||
*/
|
||||
package net.runelite.cache.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import net.runelite.http.api.xtea.XteaClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -33,14 +36,25 @@ public class XteaKeyManager
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(XteaKeyManager.class);
|
||||
|
||||
private final Map<Integer, int[]> keys = new HashMap<>();
|
||||
private Map<Integer, Integer[]> keys = new HashMap<>();
|
||||
|
||||
public void loadKeys()
|
||||
{
|
||||
XteaClient xteaClient = new XteaClient(RuneLiteAPI.CLIENT);
|
||||
|
||||
try
|
||||
{
|
||||
keys = xteaClient.get();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
logger.info("Loaded {} keys", keys.size());
|
||||
}
|
||||
|
||||
public int[] getKeys(int region)
|
||||
public Integer[] getKeys(int region)
|
||||
{
|
||||
return keys.get(region);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class MapDumperTest
|
||||
|
||||
for (int i = 0; i < MAX_REGIONS; i++)
|
||||
{
|
||||
int[] keys = keyManager.getKeys(i);
|
||||
Integer[] keysTmp = keyManager.getKeys(i);
|
||||
|
||||
int x = i >> 8;
|
||||
int y = i & 0xFF;
|
||||
@@ -95,8 +95,9 @@ public class MapDumperTest
|
||||
|
||||
Files.write(data, new File(outDir, "m" + x + "_" + y + ".dat"));
|
||||
|
||||
if (keys != null)
|
||||
if (keysTmp != null)
|
||||
{
|
||||
int[] keys = {keysTmp[0], keysTmp[1], keysTmp[2], keysTmp[3]};
|
||||
try
|
||||
{
|
||||
data = land.decompress(storage.loadArchive(land), keys);
|
||||
@@ -142,9 +143,10 @@ public class MapDumperTest
|
||||
MapDefinition mapDef = new MapLoader().load(x, y, data);
|
||||
LocationsDefinition locDef = null;
|
||||
|
||||
int[] keys = keyManager.getKeys(i);
|
||||
if (keys != null)
|
||||
Integer[] keysTmp = keyManager.getKeys(i);
|
||||
if (keysTmp != null)
|
||||
{
|
||||
int[] keys = {keysTmp[0], keysTmp[1], keysTmp[2], keysTmp[3]};
|
||||
try
|
||||
{
|
||||
data = land.decompress(storage.loadArchive(land), keys);
|
||||
|
||||
@@ -30,7 +30,6 @@ description = "Web API"
|
||||
dependencies {
|
||||
annotationProcessor(group = "org.projectlombok", name = "lombok", version = "1.18.12")
|
||||
|
||||
compileOnly(group = "javax.inject", name = "javax.inject", version = "1")
|
||||
compileOnly(group = "org.projectlombok", name = "lombok", version = "1.18.12")
|
||||
|
||||
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6")
|
||||
|
||||
@@ -30,24 +30,22 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class AccountClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccountClient.class);
|
||||
|
||||
private final OkHttpClient client;
|
||||
private UUID uuid;
|
||||
|
||||
public AccountClient()
|
||||
{
|
||||
}
|
||||
|
||||
public AccountClient(UUID uuid)
|
||||
public void setUuid(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
@@ -60,13 +58,13 @@ public class AccountClient
|
||||
.addQueryParameter("uuid", uuid.toString())
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class);
|
||||
@@ -84,16 +82,16 @@ public class AccountClient
|
||||
.addPathSegment("logout")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
logger.debug("Sent logout request");
|
||||
log.debug("Sent logout request");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +102,8 @@ public class AccountClient
|
||||
.addPathSegment("session-check")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
return Observable.fromCallable(() ->
|
||||
{
|
||||
Request request = new Request.Builder()
|
||||
@@ -113,13 +111,13 @@ public class AccountClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
return response.isSuccessful();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.debug("Unable to verify session", ex);
|
||||
log.debug("Unable to verify session", ex);
|
||||
return true; // assume it is still valid if the server is unreachable
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,16 +28,19 @@ import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class ChatClient
|
||||
{
|
||||
|
||||
private static final RequestBody body = RequestBody.Companion.create(new byte[0], null);
|
||||
private final OkHttpClient client;
|
||||
|
||||
public boolean submitKc(String username, String boss, int kc) throws IOException
|
||||
{
|
||||
@@ -49,13 +52,12 @@ public class ChatClient
|
||||
.addQueryParameter("kc", Integer.toString(kc))
|
||||
.build();
|
||||
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.post(RequestBody.create(null, new byte[0]))
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -74,7 +76,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -98,7 +100,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -116,7 +118,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -143,7 +145,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -161,7 +163,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -192,7 +194,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -211,7 +213,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -235,7 +237,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -253,7 +255,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -280,7 +282,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -299,7 +301,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -328,7 +330,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
return response.isSuccessful();
|
||||
}
|
||||
@@ -346,7 +348,7 @@ public class ChatClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
|
||||
@@ -30,44 +30,41 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
public class ConfigClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConfigClient.class);
|
||||
|
||||
private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain");
|
||||
|
||||
private final OkHttpClient client;
|
||||
private final UUID uuid;
|
||||
|
||||
public ConfigClient(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Configuration get() throws IOException
|
||||
{
|
||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
.addPathSegment("config")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class);
|
||||
@@ -87,7 +84,7 @@ public class ConfigClient
|
||||
.addPathSegment(key)
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.put(RequestBody.create(TEXT_PLAIN, value))
|
||||
@@ -95,12 +92,12 @@ public class ConfigClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
{
|
||||
logger.warn("Unable to synchronize configuration item", e);
|
||||
log.warn("Unable to synchronize configuration item", e);
|
||||
future.completeExceptionally(e);
|
||||
}
|
||||
|
||||
@@ -108,7 +105,7 @@ public class ConfigClient
|
||||
public void onResponse(Call call, Response response)
|
||||
{
|
||||
response.close();
|
||||
logger.debug("Synchronized configuration value '{}' to '{}'", key, value);
|
||||
log.debug("Synchronized configuration value '{}' to '{}'", key, value);
|
||||
future.complete(null);
|
||||
}
|
||||
});
|
||||
@@ -125,7 +122,7 @@ public class ConfigClient
|
||||
.addPathSegment(key)
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.delete()
|
||||
@@ -133,12 +130,12 @@ public class ConfigClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
{
|
||||
logger.warn("Unable to unset configuration item", e);
|
||||
log.warn("Unable to unset configuration item", e);
|
||||
future.completeExceptionally(e);
|
||||
}
|
||||
|
||||
@@ -146,7 +143,7 @@ public class ConfigClient
|
||||
public void onResponse(Call call, Response response)
|
||||
{
|
||||
response.close();
|
||||
logger.debug("Unset configuration value '{}'", key);
|
||||
log.debug("Unset configuration value '{}'", key);
|
||||
future.complete(null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,23 +25,26 @@
|
||||
package net.runelite.http.api.examine;
|
||||
|
||||
import java.io.IOException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ExamineClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExamineClient.class);
|
||||
|
||||
private static final MediaType TEXT = MediaType.parse("text");
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
public void submitObject(int id, String text)
|
||||
{
|
||||
submit("object", id, text);
|
||||
@@ -65,7 +68,7 @@ public class ExamineClient
|
||||
.addPathSegment(Integer.toString(id))
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
RequestBody body = RequestBody.Companion.create(text, TEXT);
|
||||
Request request = new Request.Builder()
|
||||
@@ -73,19 +76,19 @@ public class ExamineClient
|
||||
.post(body)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
{
|
||||
logger.warn("Error submitting examine", e);
|
||||
log.warn("Error submitting examine", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response)
|
||||
{
|
||||
response.close();
|
||||
logger.debug("Submitted examine info for {} {}: {}", type, id, text);
|
||||
log.debug("Submitted examine info for {} {}: {}", type, id, text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,34 +28,27 @@ import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import javax.inject.Inject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class FeedClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(FeedClient.class);
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@Inject
|
||||
public FeedClient(OkHttpClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public FeedResult lookupFeed() throws IOException
|
||||
{
|
||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
.addPathSegment("feed.js")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
@@ -65,7 +58,7 @@ public class FeedClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("Error looking up feed: {}", response);
|
||||
log.debug("Error looking up feed: {}", response);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.http.api.ge;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
@@ -34,15 +35,19 @@ import static net.runelite.http.api.RuneLiteAPI.JSON;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class GrandExchangeClient
|
||||
{
|
||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@Setter
|
||||
private UUID uuid;
|
||||
@Setter
|
||||
@@ -70,7 +75,7 @@ public class GrandExchangeClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
package net.runelite.http.api.hiscore;
|
||||
|
||||
import java.io.IOException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.apache.commons.csv.CSVFormat;
|
||||
@@ -35,8 +36,11 @@ import org.apache.commons.csv.CSVParser;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class HiscoreClient
|
||||
{
|
||||
private final OkHttpClient client;
|
||||
|
||||
public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException
|
||||
{
|
||||
return lookup(username, endpoint.getHiscoreURL());
|
||||
@@ -97,7 +101,7 @@ public class HiscoreClient
|
||||
|
||||
String responseStr;
|
||||
|
||||
try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute())
|
||||
try (Response okresponse = client.newCall(okrequest).execute())
|
||||
{
|
||||
if (!okresponse.isSuccessful())
|
||||
{
|
||||
|
||||
@@ -34,28 +34,21 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.directory.SearchResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class ItemClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ItemClient.class);
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@Inject
|
||||
public ItemClient(OkHttpClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public ItemPrice lookupItemPrice(int itemId) throws IOException
|
||||
{
|
||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
@@ -64,7 +57,7 @@ public class ItemClient
|
||||
.addPathSegment("price")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
@@ -74,7 +67,7 @@ public class ItemClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("Error looking up item {}: {}", itemId, response);
|
||||
log.debug("Error looking up item {}: {}", itemId, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -100,7 +93,7 @@ public class ItemClient
|
||||
|
||||
HttpUrl url = urlBuilder.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
@@ -110,7 +103,7 @@ public class ItemClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("Error looking up items {}: {}", Arrays.toString(itemIds), response);
|
||||
log.debug("Error looking up items {}: {}", Arrays.toString(itemIds), response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -131,7 +124,7 @@ public class ItemClient
|
||||
.addPathSegment("icon")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
@@ -143,7 +136,7 @@ public class ItemClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("Error grabbing icon {}: {}", itemId, response);
|
||||
log.debug("Error grabbing icon {}: {}", itemId, response);
|
||||
return Observable.just(null);
|
||||
}
|
||||
|
||||
@@ -164,7 +157,7 @@ public class ItemClient
|
||||
.addQueryParameter("query", itemName)
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
return Observable.defer(() ->
|
||||
{
|
||||
@@ -176,7 +169,7 @@ public class ItemClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("Error looking up item {}: {}", itemName, response);
|
||||
log.debug("Error looking up item {}: {}", itemName, response);
|
||||
return Observable.just(null);
|
||||
}
|
||||
|
||||
@@ -198,7 +191,7 @@ public class ItemClient
|
||||
|
||||
HttpUrl url = urlBuilder.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
return Observable.fromCallable(() ->
|
||||
{
|
||||
@@ -235,7 +228,7 @@ public class ItemClient
|
||||
.addPathSegment("stats.ids.min.json")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI {}", url);
|
||||
log.debug("Built URI {}", url);
|
||||
return Observable.fromCallable(() ->
|
||||
{
|
||||
Request request = new Request.Builder()
|
||||
|
||||
@@ -41,6 +41,7 @@ import static net.runelite.http.api.RuneLiteAPI.JSON;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
@@ -51,6 +52,7 @@ public class LootTrackerClient
|
||||
{
|
||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||
|
||||
private final OkHttpClient client;
|
||||
private final UUID uuid;
|
||||
|
||||
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
|
||||
@@ -68,7 +70,7 @@ public class LootTrackerClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
@@ -100,7 +102,7 @@ public class LootTrackerClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
@@ -133,7 +135,7 @@ public class LootTrackerClient
|
||||
.url(builder.build())
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
|
||||
@@ -29,15 +29,20 @@ import io.reactivex.rxjava3.core.Observable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class OSBGrandExchangeClient
|
||||
{
|
||||
private final OkHttpClient client;
|
||||
|
||||
public Observable<OSBGrandExchangeResult> lookupItem(int itemId)
|
||||
{
|
||||
final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
@@ -50,23 +55,23 @@ public class OSBGrandExchangeClient
|
||||
|
||||
return Observable.defer(() ->
|
||||
{
|
||||
Request request = new Request.Builder()
|
||||
final Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
|
||||
try (final Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
return Observable.error(new IOException("Error looking up item id: " + response));
|
||||
}
|
||||
|
||||
|
||||
final InputStream in = response.body().byteStream();
|
||||
return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OSBGrandExchangeResult.class));
|
||||
}
|
||||
catch (JsonParseException e)
|
||||
catch (JsonParseException ex)
|
||||
{
|
||||
return Observable.error(e);
|
||||
return Observable.error(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,35 +29,28 @@ import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import javax.inject.Inject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.CacheControl;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class WorldClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(WorldClient.class);
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@Inject
|
||||
public WorldClient(OkHttpClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public WorldResult lookupWorlds() throws IOException
|
||||
{
|
||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
.addPathSegment("worlds.js")
|
||||
.build();
|
||||
|
||||
logger.debug("Built URI: {}", url);
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
@@ -68,7 +61,7 @@ public class WorldClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("Error looking up worlds: {}", response);
|
||||
log.debug("Error looking up worlds: {}", response);
|
||||
throw new IOException("unsuccessful response looking up worlds");
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,24 @@
|
||||
package net.runelite.http.api.xp;
|
||||
|
||||
import java.io.IOException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
public class XpClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(XpClient.class);
|
||||
private final OkHttpClient client;
|
||||
|
||||
public XpClient(OkHttpClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void update(String username)
|
||||
{
|
||||
@@ -50,19 +56,19 @@ public class XpClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
{
|
||||
logger.warn("Error submitting xp track", e);
|
||||
log.warn("Error submitting xp track", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response)
|
||||
{
|
||||
response.close();
|
||||
logger.debug("Submitted xp track for {}", username);
|
||||
log.debug("Submitted xp track for {}", username);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,18 +30,21 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class XteaClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(XteaClient.class);
|
||||
private final OkHttpClient client;
|
||||
|
||||
public void submit(int region, int[] keys)
|
||||
{
|
||||
@@ -55,16 +58,18 @@ public class XteaClient
|
||||
.addQueryParameter("key4", String.valueOf(keys[3]))
|
||||
.build();
|
||||
|
||||
log.debug("Built URI: {}", url);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
client.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e)
|
||||
{
|
||||
logger.warn("unable to submit xtea keys", e);
|
||||
log.warn("unable to submit xtea keys", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +79,7 @@ public class XteaClient
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
logger.debug("unsuccessful xtea response");
|
||||
log.debug("unsuccessful xtea response");
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -95,7 +100,7 @@ public class XteaClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
InputStream in = response.body().byteStream();
|
||||
// CHECKSTYLE:OFF
|
||||
|
||||
@@ -407,11 +407,6 @@ public interface Client extends GameShell
|
||||
*/
|
||||
IndexDataBase getIndexScripts();
|
||||
|
||||
/**
|
||||
* Gets the config archive, containing Varplayer and Varbit definitions
|
||||
*/
|
||||
IndexDataBase getConfigArchive();
|
||||
|
||||
/**
|
||||
* Gets the config index.
|
||||
*/
|
||||
@@ -498,6 +493,7 @@ public interface Client extends GameShell
|
||||
* @param widget the widget info
|
||||
* @return the widget
|
||||
*/
|
||||
@Nullable
|
||||
Widget getWidget(WidgetInfo widget);
|
||||
|
||||
/**
|
||||
@@ -510,6 +506,7 @@ public interface Client extends GameShell
|
||||
* @param childId the child widget ID
|
||||
* @return the widget corresponding to the group and child pair
|
||||
*/
|
||||
@Nullable
|
||||
Widget getWidget(int groupId, int childId);
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ public final class EnumID
|
||||
{
|
||||
public static final int MUSIC_TRACK_NAMES = 812;
|
||||
public static final int MUSIC_TRACK_IDS = 819;
|
||||
public static final int XPDROP_COLORS = 1169;
|
||||
|
||||
/**
|
||||
* Translates spellbook varbit into enum ID
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,14 @@ public enum InventoryID
|
||||
* Reward from fishing trawler
|
||||
*/
|
||||
FISHING_TRAWLER_REWARD(0),
|
||||
/**
|
||||
* The trade inventory.
|
||||
*/
|
||||
TRADE(90),
|
||||
/**
|
||||
* The other trade inventory.
|
||||
*/
|
||||
TRADEOTHER(90 | 0x8000),
|
||||
/**
|
||||
* Standard player inventory.
|
||||
*/
|
||||
|
||||
@@ -75,6 +75,14 @@ public interface ItemDefinition
|
||||
*/
|
||||
int getPrice();
|
||||
|
||||
/**
|
||||
* Get the high alchemy price for this item. All items have a high alchemy price,
|
||||
* but not all items can be alched.
|
||||
*
|
||||
* @return the high alch price
|
||||
*/
|
||||
int getHaPrice();
|
||||
|
||||
/**
|
||||
* Checks whether the item is members only.
|
||||
*
|
||||
|
||||
@@ -11578,5 +11578,10 @@ public final class ItemID
|
||||
public static final int ZIGGY = 24849;
|
||||
public static final int SOFT_CLAY_PACK_24851 = 24851;
|
||||
public static final int BAG_FULL_OF_GEMS_24853 = 24853;
|
||||
public static final int MYTHICAL_MAX_CAPE = 24855;
|
||||
public static final int MYTHICAL_MAX_HOOD = 24857;
|
||||
public static final int WARRIOR_PATH_STARTER_KIT = 24859;
|
||||
public static final int WIZARD_PATH_STARTER_KIT = 24860;
|
||||
public static final int RANGER_PATH_STARTER_KIT = 24861;
|
||||
/* This file is automatically generated. Do not edit. */
|
||||
}
|
||||
|
||||
@@ -13068,5 +13068,7 @@ public final class NullItemID
|
||||
public static final int NULL_24850 = 24850;
|
||||
public static final int NULL_24852 = 24852;
|
||||
public static final int NULL_24854 = 24854;
|
||||
public static final int NULL_24856 = 24856;
|
||||
public static final int NULL_24858 = 24858;
|
||||
/* This file is automatically generated. Do not edit. */
|
||||
}
|
||||
|
||||
@@ -20090,5 +20090,6 @@ public final class ObjectID
|
||||
public static final int STAIRS_39609 = 39609;
|
||||
public static final int CRYPT = 39617;
|
||||
public static final int COFFIN_39620 = 39620;
|
||||
public static final int MOUNTED_MAX_CAPE_39621 = 39621;
|
||||
/* This file is automatically generated. Do not edit. */
|
||||
}
|
||||
|
||||
@@ -31,6 +31,13 @@ import net.runelite.api.kit.KitType;
|
||||
*/
|
||||
public interface PlayerAppearance
|
||||
{
|
||||
/**
|
||||
* Checks if the player is female.
|
||||
*
|
||||
* @return true if the player is female
|
||||
*/
|
||||
boolean isFemale();
|
||||
|
||||
/**
|
||||
* Gets an array of IDs related to equipment slots.
|
||||
* <p>
|
||||
|
||||
@@ -167,8 +167,8 @@ public final class ScriptID
|
||||
*
|
||||
* Updates the VarClientInts (73, 74) to this same value
|
||||
* <ul>
|
||||
* <li> int Reset zoom position </li>
|
||||
* <li> int Reset zoom position </li>
|
||||
* <li> int Reset zoom position for fixed viewport mode</li>
|
||||
* <li> int Reset zoom position for resizable viewport mode</li>
|
||||
* </ul>
|
||||
*/
|
||||
@ScriptArguments(integer = 2)
|
||||
@@ -241,12 +241,6 @@ public final class ScriptID
|
||||
@ScriptArguments(integer = 18)
|
||||
public static final int BANKMAIN_SEARCH_TOGGLE = 281;
|
||||
|
||||
/**
|
||||
* Builds the items kept on death widget
|
||||
*/
|
||||
@ScriptArguments(integer = 4, string = 2)
|
||||
public static final int DEATH_KEEP_BUILD = 1601;
|
||||
|
||||
/**
|
||||
* Builds the widget that holds all of the players inside a friends chat
|
||||
*/
|
||||
@@ -329,4 +323,13 @@ public final class ScriptID
|
||||
*/
|
||||
@ScriptArguments(integer = 2)
|
||||
public static final int TOPLEVEL_REDRAW = 907;
|
||||
|
||||
/**
|
||||
* Called to set position of an xpdrop text and sprite(s)
|
||||
* <ul>
|
||||
* <li> XP drop parent component </li>
|
||||
* </ul>
|
||||
*/
|
||||
@ScriptArguments(integer = 4, string = 1)
|
||||
public static final int XPDROPS_SETDROPSIZE = 996;
|
||||
}
|
||||
|
||||
+4
-4
@@ -25,13 +25,13 @@
|
||||
package net.runelite.api.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Actor;
|
||||
|
||||
/**
|
||||
* An event when a player dies.
|
||||
* An event fired when an actor dies.
|
||||
*/
|
||||
@Value
|
||||
public class PlayerDeath implements Event
|
||||
public class ActorDeath implements Event
|
||||
{
|
||||
Player player;
|
||||
Actor actor;
|
||||
}
|
||||
@@ -170,6 +170,7 @@ public class WidgetID
|
||||
public static final int ADVENTURE_LOG_ID = 187;
|
||||
public static final int GENERIC_SCROLL_GROUP_ID = 625;
|
||||
public static final int GAUNTLET_TIMER_GROUP_ID = 637;
|
||||
public static final int HEALTH_OVERLAY_BAR_GROUP_ID = 303;
|
||||
|
||||
static class WorldMap
|
||||
{
|
||||
@@ -1357,4 +1358,9 @@ public class WidgetID
|
||||
{
|
||||
static final int CONTAINER = 2;
|
||||
}
|
||||
|
||||
static class EncounterHealthBar
|
||||
{
|
||||
static final int CONTAINER = 6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,7 +890,9 @@ public enum WidgetInfo
|
||||
SECOND_TRADING_WITH_MY_ITEMS(WidgetID.PLAYER_TRADE_CONFIRM_GROUP_ID, WidgetID.TradeScreen.SECOND_MY_ITEMS),
|
||||
SECOND_TRADING_WITH_THEIR_ITEMS(WidgetID.PLAYER_TRADE_CONFIRM_GROUP_ID, WidgetID.TradeScreen.SECOND_THEIR_ITEMS),
|
||||
|
||||
GAUNTLET_TIMER_CONTAINER(WidgetID.GAUNTLET_TIMER_GROUP_ID, WidgetID.GauntletTimer.CONTAINER);
|
||||
GAUNTLET_TIMER_CONTAINER(WidgetID.GAUNTLET_TIMER_GROUP_ID, WidgetID.GauntletTimer.CONTAINER),
|
||||
|
||||
HEALTH_OVERLAY_BAR(WidgetID.HEALTH_OVERLAY_BAR_GROUP_ID, WidgetID.EncounterHealthBar.CONTAINER);
|
||||
|
||||
private final int groupId;
|
||||
private final int childId;
|
||||
|
||||
@@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.events.ClientShutdown;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -44,9 +45,10 @@ public class ClientSessionManager
|
||||
|
||||
|
||||
@Inject
|
||||
ClientSessionManager(EventBus eventBus)
|
||||
ClientSessionManager(EventBus eventBus,
|
||||
OkHttpClient okHttpClient)
|
||||
{
|
||||
this.sessionClient = new SessionClient();
|
||||
this.sessionClient = new SessionClient(okHttpClient);
|
||||
|
||||
eventBus.subscribe(ClientShutdown.class, this, (e) ->
|
||||
{
|
||||
|
||||
@@ -214,6 +214,28 @@ public class Notifier
|
||||
|
||||
FlashNotification flashNotification = runeLiteConfig.flashNotification();
|
||||
|
||||
if (Instant.now().minusMillis(MINIMUM_FLASH_DURATION_MILLIS).isAfter(flashStart))
|
||||
{
|
||||
switch (flashNotification)
|
||||
{
|
||||
case FLASH_TWO_SECONDS:
|
||||
case SOLID_TWO_SECONDS:
|
||||
flashStart = null;
|
||||
return;
|
||||
case SOLID_UNTIL_CANCELLED:
|
||||
case FLASH_UNTIL_CANCELLED:
|
||||
// Any interaction with the client since the notification started will cancel it after the minimum duration
|
||||
if ((client.getMouseIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getKeyboardIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getMouseLastPressedMillis() > mouseLastPressedMillis) && clientUI.isFocused())
|
||||
{
|
||||
flashStart = null;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (client.getGameCycle() % 40 >= 20
|
||||
// For solid colour, fall through every time.
|
||||
&& (flashNotification == FlashNotification.FLASH_TWO_SECONDS
|
||||
@@ -226,29 +248,6 @@ public class Notifier
|
||||
graphics.setColor(FLASH_COLOR);
|
||||
graphics.fill(new Rectangle(client.getCanvas().getSize()));
|
||||
graphics.setColor(color);
|
||||
|
||||
if (!Instant.now().minusMillis(MINIMUM_FLASH_DURATION_MILLIS).isAfter(flashStart))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (flashNotification)
|
||||
{
|
||||
case FLASH_TWO_SECONDS:
|
||||
case SOLID_TWO_SECONDS:
|
||||
flashStart = null;
|
||||
break;
|
||||
case SOLID_UNTIL_CANCELLED:
|
||||
case FLASH_UNTIL_CANCELLED:
|
||||
// Any interaction with the client since the notification started will cancel it after the minimum duration
|
||||
if ((client.getMouseIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getKeyboardIdleTicks() < MINIMUM_FLASH_DURATION_TICKS
|
||||
|| client.getMouseLastPressedMillis() > mouseLastPressedMillis) && clientUI.isFocused())
|
||||
{
|
||||
flashStart = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendNotification(
|
||||
|
||||
@@ -44,6 +44,10 @@ import java.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -52,6 +56,9 @@ import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.OptionException;
|
||||
import joptsimple.OptionParser;
|
||||
@@ -102,8 +109,11 @@ import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
|
||||
import net.runelite.client.util.Groups;
|
||||
import net.runelite.client.util.WorldUtil;
|
||||
import net.runelite.client.ws.PartyService;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
import net.runelite.http.api.worlds.WorldResult;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
@@ -118,12 +128,13 @@ public class RuneLite
|
||||
public static final File EXTERNALPLUGIN_DIR = new File(RUNELITE_DIR, "externalmanager");
|
||||
public static final File SCREENSHOT_DIR = new File(RUNELITE_DIR, "screenshots");
|
||||
public static final File LOGS_DIR = new File(RUNELITE_DIR, "logs");
|
||||
public static final File PLUGINS_DIR = new File(RUNELITE_DIR, "plugins");
|
||||
public static final File DEFAULT_CONFIG_FILE = new File(RUNELITE_DIR, "runeliteplus.properties");
|
||||
public static final Locale SYSTEM_LOCALE = Locale.getDefault();
|
||||
public static boolean allowPrivateServer = false;
|
||||
public static String uuid = UUID.randomUUID().toString();
|
||||
|
||||
private static final int MAX_OKHTTP_CACHE_SIZE = 20 * 1024 * 1024; // 20mb
|
||||
|
||||
@Getter
|
||||
private static Injector injector;
|
||||
|
||||
@@ -239,6 +250,8 @@ public class RuneLite
|
||||
parser.accepts("debug", "Show extra debugging output");
|
||||
parser.accepts("safe-mode", "Disables external plugins and the GPU plugin");
|
||||
parser.accepts("no-splash", "Do not show the splash screen");
|
||||
parser.accepts("insecure-skip-tls-verification", "Disables TLS verification");
|
||||
|
||||
final ArgumentAcceptingOptionSpec<String> proxyInfo = parser
|
||||
.accepts("proxy")
|
||||
.withRequiredArg().ofType(String.class);
|
||||
@@ -366,7 +379,18 @@ public class RuneLite
|
||||
log.error("Unable to load settings", ex);
|
||||
}
|
||||
|
||||
final ClientLoader clientLoader = new ClientLoader(options.valueOf(updateMode));
|
||||
final OkHttpClient.Builder okHttpClientBuilder = RuneLiteAPI.CLIENT.newBuilder()
|
||||
.cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE));
|
||||
|
||||
final boolean insecureSkipTlsVerification = options.has("insecure-skip-tls-verification");
|
||||
if (insecureSkipTlsVerification)
|
||||
{
|
||||
setupInsecureTrustManager(okHttpClientBuilder);
|
||||
}
|
||||
|
||||
final OkHttpClient okHttpClient = okHttpClientBuilder.build();
|
||||
|
||||
final ClientLoader clientLoader = new ClientLoader(okHttpClient, options.valueOf(updateMode));
|
||||
Completable.fromAction(clientLoader::get)
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.subscribe();
|
||||
@@ -401,6 +425,7 @@ public class RuneLite
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
injector = Guice.createInjector(new RuneLiteModule(
|
||||
okHttpClient,
|
||||
clientLoader,
|
||||
options.has("safe-mode"),
|
||||
configFile));
|
||||
@@ -657,4 +682,37 @@ public class RuneLite
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupInsecureTrustManager(OkHttpClient.Builder okHttpClientBuilder)
|
||||
{
|
||||
try
|
||||
{
|
||||
X509TrustManager trustManager = new X509TrustManager()
|
||||
{
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers()
|
||||
{
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
};
|
||||
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, new TrustManager[]{trustManager}, new SecureRandom());
|
||||
okHttpClientBuilder.sslSocketFactory(sc.getSocketFactory(), trustManager);
|
||||
}
|
||||
catch (NoSuchAlgorithmException | KeyManagementException ex)
|
||||
{
|
||||
log.warn("unable to setup insecure trust manager", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.util.DeferredEventBus;
|
||||
import net.runelite.client.util.ExecutorServiceExceptionLogger;
|
||||
import net.runelite.client.util.NonScheduledExecutorServiceExceptionLogger;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Cache;
|
||||
import net.runelite.http.api.chat.ChatClient;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -67,8 +66,7 @@ import org.slf4j.LoggerFactory;
|
||||
@AllArgsConstructor
|
||||
public class RuneLiteModule extends AbstractModule
|
||||
{
|
||||
private static final int MAX_OKHTTP_CACHE_SIZE = 20 * 1024 * 1024; // 20mb
|
||||
|
||||
private final OkHttpClient okHttpClient;
|
||||
private final Supplier<Applet> clientLoader;
|
||||
private final boolean safeMode;
|
||||
private final File config;
|
||||
@@ -78,9 +76,7 @@ public class RuneLiteModule extends AbstractModule
|
||||
{
|
||||
bindConstant().annotatedWith(Names.named("safeMode")).to(safeMode);
|
||||
bind(File.class).annotatedWith(Names.named("config")).toInstance(config);
|
||||
bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT.newBuilder()
|
||||
.cache(new Cache(new File(RuneLite.CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE))
|
||||
.build());
|
||||
bind(OkHttpClient.class).toInstance(okHttpClient);
|
||||
bind(MenuManager.class);
|
||||
bind(ChatMessageManager.class);
|
||||
bind(ItemManager.class);
|
||||
@@ -169,4 +165,11 @@ public class RuneLiteModule extends AbstractModule
|
||||
|
||||
return new NonScheduledExecutorServiceExceptionLogger(executor);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ChatClient provideChatClient(OkHttpClient okHttpClient)
|
||||
{
|
||||
return new ChatClient(okHttpClient);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,18 @@ import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
@AllArgsConstructor
|
||||
class SessionClient
|
||||
{
|
||||
private final OkHttpClient okHttpClient;
|
||||
|
||||
Observable<UUID> openSession()
|
||||
{
|
||||
final HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
||||
@@ -47,7 +52,7 @@ class SessionClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = okHttpClient.newCall(request).execute())
|
||||
{
|
||||
return RuneLiteAPI.GSON.fromJson(response.body().string(), UUID.class);
|
||||
}
|
||||
@@ -67,11 +72,11 @@ class SessionClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = okHttpClient.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
throw new IOException("Unsuccesful ping");
|
||||
throw new IOException("Unsuccessful ping");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -90,7 +95,7 @@ class SessionClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).execute().close();
|
||||
okHttpClient.newCall(request).execute().close();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.runelite.client.ws.WSClient;
|
||||
import net.runelite.http.api.account.AccountClient;
|
||||
import net.runelite.http.api.account.OAuthResponse;
|
||||
import net.runelite.http.api.ws.messages.LoginResponse;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -59,12 +60,17 @@ public class SessionManager
|
||||
|
||||
private final EventBus eventBus;
|
||||
private final WSClient wsClient;
|
||||
private final AccountClient accountClient;
|
||||
|
||||
@Inject
|
||||
private SessionManager(EventBus eventBus, WSClient wsClient)
|
||||
private SessionManager(
|
||||
EventBus eventBus,
|
||||
WSClient wsClient,
|
||||
OkHttpClient okHttpClient)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
this.wsClient = wsClient;
|
||||
this.accountClient = new AccountClient(okHttpClient);
|
||||
|
||||
this.eventBus.subscribe(LoginResponse.class, this, this::onLoginResponse);
|
||||
}
|
||||
@@ -92,7 +98,7 @@ public class SessionManager
|
||||
}
|
||||
|
||||
// Check if session is still valid
|
||||
AccountClient accountClient = new AccountClient(session.getUuid());
|
||||
accountClient.setUuid(session.getUuid());
|
||||
accountClient.sessionCheck()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(b ->
|
||||
@@ -169,10 +175,10 @@ public class SessionManager
|
||||
|
||||
log.debug("Logging out of account {}", accountSession.getUsername());
|
||||
|
||||
AccountClient client = new AccountClient(accountSession.getUuid());
|
||||
accountClient.setUuid(accountSession.getUuid());
|
||||
try
|
||||
{
|
||||
client.logout();
|
||||
accountClient.logout();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -188,13 +194,13 @@ public class SessionManager
|
||||
{
|
||||
// If a session is already open, use that id. Otherwise generate a new id.
|
||||
UUID uuid = wsClient.getSessionId() != null ? wsClient.getSessionId() : UUID.randomUUID();
|
||||
AccountClient loginClient = new AccountClient(uuid);
|
||||
accountClient.setUuid(uuid);
|
||||
|
||||
final OAuthResponse login;
|
||||
|
||||
try
|
||||
{
|
||||
login = loginClient.login();
|
||||
login = accountClient.login();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
@@ -33,11 +33,10 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Singleton
|
||||
public class HiscoreManager
|
||||
@@ -53,12 +52,13 @@ public class HiscoreManager
|
||||
static final HiscoreResult EMPTY = new HiscoreResult();
|
||||
static final HiscoreResult NONE = new HiscoreResult();
|
||||
|
||||
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
||||
private final LoadingCache<HiscoreKey, HiscoreResult> hiscoreCache;
|
||||
private final HiscoreClient hiscoreClient;
|
||||
|
||||
@Inject
|
||||
public HiscoreManager(Client client, ScheduledExecutorService executor, ClientThread clientThread)
|
||||
public HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient)
|
||||
{
|
||||
hiscoreClient = new HiscoreClient(okHttpClient);
|
||||
hiscoreCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(128L)
|
||||
.expireAfterWrite(1, TimeUnit.HOURS)
|
||||
|
||||
@@ -48,7 +48,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Constants;
|
||||
import static net.runelite.api.Constants.CLIENT_DEFAULT_ZOOM;
|
||||
import static net.runelite.api.Constants.HIGH_ALCHEMY_MULTIPLIER;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemDefinition;
|
||||
import net.runelite.api.ItemID;
|
||||
@@ -63,11 +62,38 @@ import net.runelite.http.api.item.ItemClient;
|
||||
import net.runelite.http.api.item.ItemPrice;
|
||||
import net.runelite.http.api.item.ItemStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
public class ItemManager
|
||||
{
|
||||
@Value
|
||||
private static class ImageKey
|
||||
{
|
||||
private final int itemId;
|
||||
private final int itemQuantity;
|
||||
private final boolean stackable;
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class OutlineKey
|
||||
{
|
||||
private final int itemId;
|
||||
private final int itemQuantity;
|
||||
private final Color outlineColor;
|
||||
}
|
||||
|
||||
private final Client client;
|
||||
private final ClientThread clientThread;
|
||||
private final ItemClient itemClient;
|
||||
|
||||
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
||||
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
||||
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
|
||||
private final LoadingCache<Integer, ItemDefinition> itemDefinitions;
|
||||
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
|
||||
|
||||
// Worn items with weight reducing property have a different worn and inventory ItemID
|
||||
private static final ImmutableMap<Integer, Integer> WORN_ITEMS = ImmutableMap.<Integer, Integer>builder().
|
||||
put(BOOTS_OF_LIGHTNESS_89, BOOTS_OF_LIGHTNESS).
|
||||
@@ -136,14 +162,6 @@ public class ItemManager
|
||||
put(AGILITY_CAPET_13341, AGILITY_CAPET).
|
||||
put(AGILITY_CAPE_13340, AGILITY_CAPE).
|
||||
build();
|
||||
private final Client client;
|
||||
private final ClientThread clientThread;
|
||||
private final ItemClient itemClient;
|
||||
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
|
||||
private final LoadingCache<Integer, ItemDefinition> itemDefinitions;
|
||||
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
|
||||
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
||||
private Map<Integer, ItemStats> itemStats = Map.of();
|
||||
|
||||
@Inject
|
||||
public ItemManager(
|
||||
@@ -151,12 +169,11 @@ public class ItemManager
|
||||
ScheduledExecutorService executor,
|
||||
ClientThread clientThread,
|
||||
EventBus eventbus,
|
||||
ItemClient itemClient
|
||||
)
|
||||
OkHttpClient okHttpClient)
|
||||
{
|
||||
this.client = client;
|
||||
this.clientThread = clientThread;
|
||||
this.itemClient = itemClient;
|
||||
this.itemClient = new ItemClient(okHttpClient);
|
||||
|
||||
executor.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
||||
executor.submit(this::loadStats);
|
||||
@@ -322,7 +339,7 @@ public class ItemManager
|
||||
return 1000;
|
||||
}
|
||||
|
||||
return (int) Math.max(1, composition.getPrice() * HIGH_ALCHEMY_MULTIPLIER);
|
||||
return Math.max(1, composition.getHaPrice());
|
||||
}
|
||||
|
||||
public int getAlchValue(int itemID)
|
||||
@@ -336,7 +353,7 @@ public class ItemManager
|
||||
return 1000;
|
||||
}
|
||||
|
||||
return (int) Math.max(1, getItemDefinition(itemID).getPrice() * HIGH_ALCHEMY_MULTIPLIER);
|
||||
return Math.max(1, getItemDefinition(itemID).getHaPrice());
|
||||
}
|
||||
|
||||
public int getRepairValue(int itemId)
|
||||
@@ -533,20 +550,4 @@ public class ItemManager
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class ImageKey
|
||||
{
|
||||
private final int itemId;
|
||||
private final int itemQuantity;
|
||||
private final boolean stackable;
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class OutlineKey
|
||||
{
|
||||
private final int itemId;
|
||||
private final int itemQuantity;
|
||||
private final Color outlineColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,14 @@ import net.runelite.http.api.hiscore.HiscoreClient;
|
||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||
import net.runelite.http.api.item.ItemEquipmentStats;
|
||||
import net.runelite.http.api.item.ItemStats;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerManager
|
||||
{
|
||||
private static final HiscoreClient HISCORE_CLIENT = new HiscoreClient();
|
||||
private final HiscoreClient hiscoreClient;
|
||||
private final Client client;
|
||||
private final ItemManager itemManager;
|
||||
private final EventBus eventBus;
|
||||
@@ -54,13 +55,16 @@ public class PlayerManager
|
||||
final Client client,
|
||||
final EventBus eventBus,
|
||||
final ItemManager itemManager,
|
||||
final FriendChatManager friendChatManager
|
||||
final FriendChatManager friendChatManager,
|
||||
final OkHttpClient okHttpClient
|
||||
)
|
||||
{
|
||||
this.client = client;
|
||||
this.itemManager = itemManager;
|
||||
this.eventBus = eventBus;
|
||||
this.friendChatManager = friendChatManager;
|
||||
this.hiscoreClient = new HiscoreClient(okHttpClient);
|
||||
|
||||
eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned);
|
||||
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
|
||||
eventBus.subscribe(PlayerAppearanceChanged.class, this, this::onAppearenceChanged);
|
||||
@@ -174,7 +178,7 @@ public class PlayerManager
|
||||
{
|
||||
try
|
||||
{
|
||||
result = HISCORE_CLIENT.lookup(player.getName());
|
||||
result = hiscoreClient.lookup(player.getName());
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,7 @@ import net.runelite.client.util.RunnableExceptionLogger;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
import net.runelite.http.api.worlds.WorldClient;
|
||||
import net.runelite.http.api.worlds.WorldResult;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -59,12 +60,15 @@ public class WorldService
|
||||
private WorldResult worlds;
|
||||
|
||||
@Inject
|
||||
private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, WorldClient worldClient,
|
||||
EventBus eventBus)
|
||||
private WorldService(
|
||||
Client client,
|
||||
ScheduledExecutorService scheduledExecutorService,
|
||||
OkHttpClient okHttpClient,
|
||||
EventBus eventBus)
|
||||
{
|
||||
this.client = client;
|
||||
this.scheduledExecutorService = scheduledExecutorService;
|
||||
this.worldClient = worldClient;
|
||||
this.worldClient = new WorldClient(okHttpClient);
|
||||
this.eventBus = eventBus;
|
||||
|
||||
scheduledExecutorService.scheduleWithFixedDelay(RunnableExceptionLogger.wrap(this::tick), 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES);
|
||||
|
||||
@@ -184,6 +184,11 @@ public class ChatboxItemSearch extends ChatboxTextInput
|
||||
@Override
|
||||
public void keyPressed(KeyEvent ev)
|
||||
{
|
||||
if (!chatboxPanelManager.shouldTakeInput())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (ev.getKeyCode())
|
||||
{
|
||||
case KeyEvent.VK_ENTER:
|
||||
|
||||
+8
@@ -200,4 +200,12 @@ public class ChatboxPanelManager
|
||||
{
|
||||
return client.getWidget(WidgetInfo.CHATBOX_CONTAINER);
|
||||
}
|
||||
|
||||
public boolean shouldTakeInput()
|
||||
{
|
||||
// the search box on the world map can be focused, and chat input goes there, even
|
||||
// though the chatbox still has its key listener.
|
||||
Widget worldMapSearch = client.getWidget(WidgetInfo.WORLD_MAP_SEARCH);
|
||||
return worldMapSearch == null || client.getVar(VarClientInt.WORLD_MAP_SEARCH_FOCUSED) != 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,6 +609,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e)
|
||||
{
|
||||
if (!chatboxPanelManager.shouldTakeInput())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char c = e.getKeyChar();
|
||||
if (charValidator.test(c))
|
||||
{
|
||||
@@ -628,6 +633,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
||||
@Override
|
||||
public void keyPressed(KeyEvent ev)
|
||||
{
|
||||
if (!chatboxPanelManager.shouldTakeInput())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int code = ev.getKeyCode();
|
||||
if (ev.isControlDown())
|
||||
{
|
||||
|
||||
+10
@@ -178,6 +178,11 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e)
|
||||
{
|
||||
if (!chatboxPanelManager.shouldTakeInput())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char c = e.getKeyChar();
|
||||
|
||||
if (c == '\033')
|
||||
@@ -198,6 +203,11 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e)
|
||||
{
|
||||
if (!chatboxPanelManager.shouldTakeInput())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
|
||||
{
|
||||
e.consume();
|
||||
|
||||
@@ -24,4 +24,10 @@
|
||||
*/
|
||||
package net.runelite.client.input;
|
||||
|
||||
public interface KeyListener extends java.awt.event.KeyListener {}
|
||||
public interface KeyListener extends java.awt.event.KeyListener
|
||||
{
|
||||
default boolean isEnabledOnLoginScreen()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.client.util.HotkeyListener;
|
||||
|
||||
@Singleton
|
||||
public class KeyManager
|
||||
@@ -133,18 +132,13 @@ public class KeyManager
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(keyListener instanceof HotkeyListener))
|
||||
final GameState gameState = client.getGameState();
|
||||
|
||||
if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.LOGIN_SCREEN_AUTHENTICATOR)
|
||||
{
|
||||
return true;
|
||||
return keyListener.isEnabledOnLoginScreen();
|
||||
}
|
||||
|
||||
final HotkeyListener hotkeyListener = (HotkeyListener) keyListener;
|
||||
|
||||
if (hotkeyListener.isEnabledOnLogin())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return client.getGameState() != GameState.LOGIN_SCREEN;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,7 +619,6 @@ public class PluginManager
|
||||
binder.install(plugin);
|
||||
};
|
||||
Injector pluginInjector = parent.createChildInjector(pluginModule);
|
||||
pluginInjector.injectMembers(plugin);
|
||||
plugin.injector = pluginInjector;
|
||||
}
|
||||
catch (CreationException ex)
|
||||
|
||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.xtea;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
@@ -37,6 +38,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.http.api.xtea.XteaClient;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Xtea",
|
||||
@@ -45,13 +47,16 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
@Slf4j
|
||||
public class XteaPlugin extends Plugin
|
||||
{
|
||||
private final XteaClient xteaClient = new XteaClient();
|
||||
@Inject
|
||||
private XteaClient xteaClient;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
private HashMap<Integer, Integer[]> xteas;
|
||||
|
||||
@Override
|
||||
public void startUp()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -63,6 +68,12 @@ public class XteaPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
XteaClient provideXteaClient(OkHttpClient okHttpClient)
|
||||
{
|
||||
return new XteaClient(okHttpClient);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||
{
|
||||
|
||||
@@ -28,19 +28,18 @@ package net.runelite.client.rs;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.AllArgsConstructor;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
@AllArgsConstructor
|
||||
class ClientConfigLoader
|
||||
{
|
||||
private ClientConfigLoader()
|
||||
{
|
||||
}
|
||||
private final OkHttpClient okHttpClient;
|
||||
|
||||
static RSConfig fetch(HttpUrl url) throws IOException
|
||||
RSConfig fetch(HttpUrl url) throws IOException
|
||||
{
|
||||
final Request request = new Request.Builder()
|
||||
.url(url)
|
||||
@@ -48,10 +47,6 @@ class ClientConfigLoader
|
||||
|
||||
final RSConfig config = new RSConfig();
|
||||
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.connectTimeout(2000, TimeUnit.MILLISECONDS)
|
||||
.build();
|
||||
|
||||
try (final Response response = okHttpClient.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
|
||||
@@ -40,23 +40,27 @@ import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.RuneLiteSplashScreen;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Slf4j
|
||||
public class ClientLoader implements Supplier<Applet>
|
||||
{
|
||||
private static final String CONFIG_URL = "https://oldschool.runescape.com/jav_config.ws";
|
||||
private static final String BACKUP_CONFIG_URL = "https://raw.githubusercontent.com/open-osrs/hosting/master/jav_config.ws";
|
||||
|
||||
private static final int NUM_ATTEMPTS = 10;
|
||||
private final ClientUpdateCheckMode updateCheckMode;
|
||||
private Object client = null;
|
||||
|
||||
private WorldSupplier worldSupplier = new WorldSupplier();
|
||||
private final ClientConfigLoader clientConfigLoader;
|
||||
private final ClientUpdateCheckMode updateCheckMode;
|
||||
private final WorldSupplier worldSupplier;
|
||||
|
||||
private Object client;
|
||||
private RSConfig config;
|
||||
|
||||
public ClientLoader(ClientUpdateCheckMode updateCheckMode)
|
||||
public ClientLoader(OkHttpClient okHttpClient, ClientUpdateCheckMode updateCheckMode)
|
||||
{
|
||||
this.clientConfigLoader = new ClientConfigLoader(okHttpClient);
|
||||
this.updateCheckMode = updateCheckMode;
|
||||
this.worldSupplier = new WorldSupplier(okHttpClient);
|
||||
}
|
||||
|
||||
private static Applet loadRLPlus(final RSConfig config)
|
||||
@@ -178,7 +182,7 @@ public class ClientLoader implements Supplier<Applet>
|
||||
RuneLiteSplashScreen.stage(.0, "Connecting with gameserver (try " + (attempt + 1) + "/" + NUM_ATTEMPTS + ")");
|
||||
try
|
||||
{
|
||||
config = ClientConfigLoader.fetch(url);
|
||||
config = clientConfigLoader.fetch(url);
|
||||
|
||||
if (Strings.isNullOrEmpty(config.getCodeBase()) || Strings.isNullOrEmpty(config.getInitialJar()) || Strings.isNullOrEmpty(config.getInitialClass()))
|
||||
{
|
||||
@@ -200,7 +204,7 @@ public class ClientLoader implements Supplier<Applet>
|
||||
|
||||
try
|
||||
{
|
||||
RSConfig backupConfig = ClientConfigLoader.fetch(HttpUrl.parse(BACKUP_CONFIG_URL));
|
||||
RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.parse(BACKUP_CONFIG_URL));
|
||||
|
||||
if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar())
|
||||
|| Strings.isNullOrEmpty(backupConfig.getInitialClass()) || Strings.isNullOrEmpty(backupConfig.getRuneLiteWorldParam()))
|
||||
|
||||
@@ -33,15 +33,18 @@ import java.util.Queue;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
import net.runelite.http.api.worlds.WorldClient;
|
||||
import net.runelite.http.api.worlds.WorldType;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
class WorldSupplier implements Supplier<World>
|
||||
{
|
||||
private final OkHttpClient okHttpClient;
|
||||
private final Random random = new Random(System.nanoTime());
|
||||
private Queue<World> worlds = new ArrayDeque<>();
|
||||
|
||||
@@ -55,7 +58,7 @@ class WorldSupplier implements Supplier<World>
|
||||
|
||||
try
|
||||
{
|
||||
List<World> newWorlds = new WorldClient(RuneLiteAPI.CLIENT)
|
||||
List<World> newWorlds = new WorldClient(okHttpClient)
|
||||
.lookupWorlds()
|
||||
.getWorlds()
|
||||
.stream()
|
||||
|
||||
@@ -402,7 +402,7 @@ public class ClientUI
|
||||
toggleSidebar();
|
||||
}
|
||||
};
|
||||
sidebarListener.setEnabledOnLogin(true);
|
||||
sidebarListener.setEnabledOnLoginScreen(true);
|
||||
keyManager.registerKeyListener(sidebarListener);
|
||||
|
||||
final HotkeyListener pluginPanelListener = new HotkeyListener(config::panelToggleKey)
|
||||
@@ -413,7 +413,7 @@ public class ClientUI
|
||||
togglePluginPanel();
|
||||
}
|
||||
};
|
||||
pluginPanelListener.setEnabledOnLogin(true);
|
||||
pluginPanelListener.setEnabledOnLoginScreen(true);
|
||||
keyManager.registerKeyListener(pluginPanelListener);
|
||||
|
||||
// Add mouse listener
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class ThinProgressBar extends JPanel
|
||||
public void setForeground(Color color)
|
||||
{
|
||||
super.setForeground(color);
|
||||
setBackground(color.darker());
|
||||
setBackground(color.darker().darker());
|
||||
}
|
||||
|
||||
public void setMaximumValue(int maximumValue)
|
||||
|
||||
@@ -63,6 +63,7 @@ public class WidgetOverlay extends Overlay
|
||||
.put(WidgetInfo.LMS_KDA, OverlayPosition.TOP_RIGHT)
|
||||
.put(WidgetInfo.THEATRE_OF_BLOOD_HEALTH_ORBS, OverlayPosition.TOP_LEFT)
|
||||
.put(WidgetInfo.GAUNTLET_TIMER_CONTAINER, OverlayPosition.TOP_LEFT)
|
||||
.put(WidgetInfo.HEALTH_OVERLAY_BAR, OverlayPosition.TOP_CENTER)
|
||||
.build();
|
||||
|
||||
public static Collection<WidgetOverlay> createOverlays(final Client client)
|
||||
|
||||
+37
-2
@@ -28,6 +28,7 @@ import com.google.common.collect.ComparisonChain;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Objects;
|
||||
@@ -72,12 +73,12 @@ public class InfoBoxManager
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
int idx = Collections.binarySearch(infoBoxes, infoBox, (b1, b2) -> ComparisonChain
|
||||
int idx = findInsertionIndex(infoBoxes, infoBox, (b1, b2) -> ComparisonChain
|
||||
.start()
|
||||
.compare(b1.getPriority(), b2.getPriority())
|
||||
.compare(b1.getPlugin().getName(), b2.getPlugin().getName())
|
||||
.result());
|
||||
infoBoxes.add(idx < 0 ? -idx - 1 : idx, infoBox);
|
||||
infoBoxes.add(idx, infoBox);
|
||||
}
|
||||
|
||||
BufferedImage image = infoBox.getImage();
|
||||
@@ -150,4 +151,38 @@ public class InfoBoxManager
|
||||
}
|
||||
infoBox.setScaledImage(resultImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find insertion point for the given key into the given sorted list. If key already exists in the list,
|
||||
* return the index after the last occurrence.
|
||||
* @param list
|
||||
* @param key
|
||||
* @param c
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
private static <T> int findInsertionIndex(List<? extends T> list, T key, Comparator<? super T> c)
|
||||
{
|
||||
int idx = Collections.binarySearch(list, key, c);
|
||||
|
||||
if (idx < 0)
|
||||
{
|
||||
// key isn't found in the list
|
||||
return -idx - 1;
|
||||
}
|
||||
|
||||
// list(idx) is equal to key, so it is not necessary to recheck it
|
||||
for (int i = idx + 1; i < list.size(); ++i)
|
||||
{
|
||||
T cur = list.get(i);
|
||||
int cmp = c.compare(cur, key);
|
||||
if (cmp > 0)
|
||||
{
|
||||
// this is the first element which is greater
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -39,6 +39,7 @@ import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.components.LayoutableRenderableEntity;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import net.runelite.client.ui.overlay.components.TooltipComponent;
|
||||
|
||||
@Singleton
|
||||
@@ -103,12 +104,17 @@ public class TooltipOverlay extends Overlay
|
||||
if (tooltip.getComponent() != null)
|
||||
{
|
||||
entity = tooltip.getComponent();
|
||||
if (entity instanceof PanelComponent)
|
||||
{
|
||||
((PanelComponent) entity).setBackgroundColor(runeLiteConfig.overlayBackgroundColor());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final TooltipComponent tooltipComponent = new TooltipComponent();
|
||||
tooltipComponent.setModIcons(client.getModIcons());
|
||||
tooltipComponent.setText(tooltip.getText());
|
||||
tooltipComponent.setBackgroundColor(runeLiteConfig.overlayBackgroundColor());
|
||||
entity = tooltipComponent;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ package net.runelite.client.util;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.function.Supplier;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.config.Keybind;
|
||||
@@ -42,8 +41,13 @@ public abstract class HotkeyListener implements KeyListener
|
||||
private boolean isConsumingTyped = false;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean isEnabledOnLogin = false;
|
||||
private boolean enabledOnLoginScreen;
|
||||
|
||||
@Override
|
||||
public boolean isEnabledOnLoginScreen()
|
||||
{
|
||||
return enabledOnLoginScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e)
|
||||
|
||||
@@ -58,6 +58,7 @@ import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
@@ -76,6 +77,9 @@ public class ImageCapture
|
||||
@Inject
|
||||
private Notifier notifier;
|
||||
|
||||
@Inject
|
||||
private OkHttpClient okHttpClient;
|
||||
|
||||
/**
|
||||
* Saves a screenshot of the client window to the screenshot folder as a PNG,
|
||||
* and optionally uploads it to an image-hosting service.
|
||||
@@ -197,7 +201,7 @@ public class ImageCapture
|
||||
.post(RequestBody.create(JSON, json))
|
||||
.build();
|
||||
|
||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||
okHttpClient.newCall(request).enqueue(new Callback()
|
||||
{
|
||||
@Override
|
||||
public void onFailure(Call call, IOException ex)
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.runelite.http.api.ws.WebsocketGsonFactory;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
import net.runelite.http.api.ws.messages.Handshake;
|
||||
import net.runelite.http.api.ws.messages.party.PartyMessage;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
@@ -50,6 +51,7 @@ import okhttp3.WebSocketListener;
|
||||
public class WSClient extends WebSocketListener implements AutoCloseable
|
||||
{
|
||||
private final EventBus eventBus;
|
||||
private final OkHttpClient okHttpClient;
|
||||
private final Collection<Class<? extends WebsocketMessage>> messages = new HashSet<>();
|
||||
|
||||
private volatile Gson gson;
|
||||
@@ -58,9 +60,10 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
||||
private WebSocket webSocket;
|
||||
|
||||
@Inject
|
||||
private WSClient(EventBus eventBus)
|
||||
private WSClient(EventBus eventBus, OkHttpClient okHttpClient)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
this.okHttpClient = okHttpClient;
|
||||
this.gson = WebsocketGsonFactory.build(WebsocketGsonFactory.factory(messages));
|
||||
}
|
||||
|
||||
@@ -101,7 +104,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
||||
.url(RuneLiteAPI.getWsEndpoint())
|
||||
.build();
|
||||
|
||||
webSocket = RuneLiteAPI.CLIENT.newWebSocket(request, this);
|
||||
webSocket = okHttpClient.newWebSocket(request, this);
|
||||
|
||||
Handshake handshake = new Handshake();
|
||||
handshake.setSession(sessionId);
|
||||
|
||||
@@ -58,6 +58,7 @@ import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.eventbus.AccessorGenerator;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
@@ -66,6 +67,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -92,10 +94,12 @@ public class PluginManagerTest
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
{
|
||||
OkHttpClient okHttpClient = mock(OkHttpClient.class);
|
||||
|
||||
executorService = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
Injector injector = Guice.createInjector(Modules
|
||||
.override(new RuneLiteModule(() -> null, false, RuneLite.DEFAULT_CONFIG_FILE))
|
||||
.override(new RuneLiteModule(okHttpClient, () -> null, false, RuneLite.DEFAULT_CONFIG_FILE))
|
||||
.with(BoundFieldModule.of(this)));
|
||||
|
||||
RuneLite.setInjector(injector);
|
||||
@@ -157,7 +161,7 @@ public class PluginManagerTest
|
||||
{
|
||||
List<Module> modules = new ArrayList<>();
|
||||
modules.add(new GraphvizModule());
|
||||
modules.add(new RuneLiteModule(() -> null, false, RuneLite.DEFAULT_CONFIG_FILE));
|
||||
modules.add(new RuneLiteModule(mock(OkHttpClient.class), () -> null, false, RuneLite.DEFAULT_CONFIG_FILE));
|
||||
|
||||
PluginManager pluginManager = new PluginManager(false, null, null, executorService, null, null, null, null);
|
||||
pluginManager.loadCorePlugins();
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import org.junit.After;
|
||||
@@ -63,7 +64,7 @@ public class ClientConfigLoaderTest
|
||||
@Test
|
||||
public void testFetch() throws IOException
|
||||
{
|
||||
final RSConfig config = ClientConfigLoader.fetch(server.url("/"));
|
||||
final RSConfig config = new ClientConfigLoader(new OkHttpClient()).fetch(server.url("/"));
|
||||
assertEquals("http://oldschool1.runescape.com/", config.getCodeBase());
|
||||
}
|
||||
|
||||
|
||||
+33
-4
@@ -41,6 +41,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -65,16 +66,31 @@ public class InfoBoxManagerTest
|
||||
|
||||
private static class TestInfobox extends InfoBox
|
||||
{
|
||||
public TestInfobox(InfoBoxPriority infoBoxPriority)
|
||||
private static final Plugin PLUGIN = mock(Plugin.class);
|
||||
|
||||
static
|
||||
{
|
||||
super(null, mock(Plugin.class));
|
||||
when(PLUGIN.getName()).thenReturn("");
|
||||
}
|
||||
|
||||
private final String text;
|
||||
|
||||
private TestInfobox(InfoBoxPriority infoBoxPriority)
|
||||
{
|
||||
this(infoBoxPriority, null);
|
||||
}
|
||||
|
||||
private TestInfobox(InfoBoxPriority infoBoxPriority, String text)
|
||||
{
|
||||
super(null, PLUGIN);
|
||||
setPriority(infoBoxPriority);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
return null;
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,4 +110,17 @@ public class InfoBoxManagerTest
|
||||
List<InfoBoxPriority> order = infoBoxManager.getInfoBoxes().stream().map(InfoBox::getPriority).collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList(InfoBoxPriority.HIGH, InfoBoxPriority.MED, InfoBoxPriority.LOW), order);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSamePluginAndPriority()
|
||||
{
|
||||
infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "one"));
|
||||
infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "two"));
|
||||
infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "three"));
|
||||
|
||||
assertEquals(3, infoBoxManager.getInfoBoxes().size());
|
||||
assertEquals("one", infoBoxManager.getInfoBoxes().get(0).getText());
|
||||
assertEquals("two", infoBoxManager.getInfoBoxes().get(1).getText());
|
||||
assertEquals("three", infoBoxManager.getInfoBoxes().get(2).getText());
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,9 @@ import net.runelite.api.Sprite;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldArea;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ActorDeath;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.HitsplatApplied;
|
||||
import net.runelite.api.events.PlayerDeath;
|
||||
import net.runelite.api.events.SpotAnimationChanged;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.api.events.OverheadTextChanged;
|
||||
@@ -247,12 +247,10 @@ public abstract class RSActorMixin implements RSActor
|
||||
{
|
||||
if (healthRatio == 0)
|
||||
{
|
||||
if (this instanceof Player)
|
||||
{
|
||||
final PlayerDeath event = new PlayerDeath((Player) this);
|
||||
client.getCallbacks().post(PlayerDeath.class, event);
|
||||
}
|
||||
else if (this instanceof RSNPC)
|
||||
final ActorDeath event = new ActorDeath(this);
|
||||
client.getCallbacks().post(ActorDeath.class, event);
|
||||
|
||||
if (this instanceof RSNPC)
|
||||
{
|
||||
((RSNPC) this).setDead(true);
|
||||
}
|
||||
|
||||
@@ -89,4 +89,12 @@ public abstract class RSItemDefinitionMixin implements RSItemDefinition
|
||||
|
||||
return client.getRSItemDefinition(modelOverride).getModel(quantity);
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public int getHaPrice()
|
||||
{
|
||||
int price = getPrice();
|
||||
return (int) ((float) price * 0.6f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class VarbitMixin implements RSClient
|
||||
return varbit;
|
||||
}
|
||||
|
||||
byte[] fileData = getConfigArchive().getConfigData(VARBITS_GROUP, id);
|
||||
byte[] fileData = getIndexConfig().getConfigData(VARBITS_GROUP, id);
|
||||
if (fileData == null)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -459,7 +459,7 @@ public interface RSClient extends RSGameShell, Client
|
||||
|
||||
@Import("archive2")
|
||||
@Override
|
||||
RSArchive getConfigArchive();
|
||||
RSArchive getIndexConfig();
|
||||
|
||||
@Import("archive6")
|
||||
RSArchive getMusicTracks();
|
||||
|
||||
Reference in New Issue
Block a user