client: use guice provided http client everywhere
This commit is contained in:
@@ -27,6 +27,7 @@ package net.runelite.cache.util;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import net.runelite.http.api.xtea.XteaClient;
|
import net.runelite.http.api.xtea.XteaClient;
|
||||||
import net.runelite.http.api.xtea.XteaKey;
|
import net.runelite.http.api.xtea.XteaKey;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -40,7 +41,7 @@ public class XteaKeyManager
|
|||||||
|
|
||||||
public void loadKeys()
|
public void loadKeys()
|
||||||
{
|
{
|
||||||
XteaClient xteaClient = new XteaClient();
|
XteaClient xteaClient = new XteaClient(RuneLiteAPI.CLIENT);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,11 +63,6 @@
|
|||||||
<artifactId>commons-csv</artifactId>
|
<artifactId>commons-csv</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>javax.inject</groupId>
|
|
||||||
<artifactId>javax.inject</artifactId>
|
|
||||||
<version>1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -29,24 +29,22 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class AccountClient
|
public class AccountClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AccountClient.class);
|
private final OkHttpClient client;
|
||||||
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
public AccountClient()
|
public void setUuid(UUID uuid)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccountClient(UUID uuid)
|
|
||||||
{
|
{
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
@@ -59,13 +57,13 @@ public class AccountClient
|
|||||||
.addQueryParameter("uuid", uuid.toString())
|
.addQueryParameter("uuid", uuid.toString())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
InputStream in = response.body().byteStream();
|
InputStream in = response.body().byteStream();
|
||||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class);
|
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class);
|
||||||
@@ -83,16 +81,16 @@ public class AccountClient
|
|||||||
.addPathSegment("logout")
|
.addPathSegment("logout")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,20 +101,20 @@ public class AccountClient
|
|||||||
.addPathSegment("session-check")
|
.addPathSegment("session-check")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.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)
|
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
|
return true; // assume it is still valid if the server is unreachable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,19 @@ import com.google.gson.JsonParseException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class ChatClient
|
public class ChatClient
|
||||||
{
|
{
|
||||||
|
private final OkHttpClient client;
|
||||||
|
|
||||||
public boolean submitKc(String username, String boss, int kc) throws IOException
|
public boolean submitKc(String username, String boss, int kc) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
@@ -51,7 +56,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -70,7 +75,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -94,7 +99,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -112,7 +117,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -139,7 +144,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -157,7 +162,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -188,7 +193,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -207,7 +212,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -231,7 +236,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -249,7 +254,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -276,7 +281,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -294,7 +299,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -323,7 +328,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
return response.isSuccessful();
|
return response.isSuccessful();
|
||||||
}
|
}
|
||||||
@@ -341,7 +346,7 @@ public class ChatClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,44 +30,41 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class ConfigClient
|
public class ConfigClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ConfigClient.class);
|
|
||||||
|
|
||||||
private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain");
|
private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain");
|
||||||
|
|
||||||
|
private final OkHttpClient client;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public ConfigClient(UUID uuid)
|
|
||||||
{
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration get() throws IOException
|
public Configuration get() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
.addPathSegment("config")
|
.addPathSegment("config")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
|
||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
InputStream in = response.body().byteStream();
|
InputStream in = response.body().byteStream();
|
||||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class);
|
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class);
|
||||||
@@ -87,7 +84,7 @@ public class ConfigClient
|
|||||||
.addPathSegment(key)
|
.addPathSegment(key)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.put(RequestBody.create(TEXT_PLAIN, value))
|
.put(RequestBody.create(TEXT_PLAIN, value))
|
||||||
@@ -95,12 +92,12 @@ public class ConfigClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
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);
|
future.completeExceptionally(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +105,7 @@ public class ConfigClient
|
|||||||
public void onResponse(Call call, Response response)
|
public void onResponse(Call call, Response response)
|
||||||
{
|
{
|
||||||
response.close();
|
response.close();
|
||||||
logger.debug("Synchronized configuration value '{}' to '{}'", key, value);
|
log.debug("Synchronized configuration value '{}' to '{}'", key, value);
|
||||||
future.complete(null);
|
future.complete(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -125,7 +122,7 @@ public class ConfigClient
|
|||||||
.addPathSegment(key)
|
.addPathSegment(key)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.delete()
|
.delete()
|
||||||
@@ -133,12 +130,12 @@ public class ConfigClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
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);
|
future.completeExceptionally(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +143,7 @@ public class ConfigClient
|
|||||||
public void onResponse(Call call, Response response)
|
public void onResponse(Call call, Response response)
|
||||||
{
|
{
|
||||||
response.close();
|
response.close();
|
||||||
logger.debug("Unset configuration value '{}'", key);
|
log.debug("Unset configuration value '{}'", key);
|
||||||
future.complete(null);
|
future.complete(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,23 +25,26 @@
|
|||||||
package net.runelite.http.api.examine;
|
package net.runelite.http.api.examine;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ExamineClient
|
public class ExamineClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ExamineClient.class);
|
|
||||||
|
|
||||||
private static final MediaType TEXT = MediaType.parse("text");
|
private static final MediaType TEXT = MediaType.parse("text");
|
||||||
|
|
||||||
|
private final OkHttpClient client;
|
||||||
|
|
||||||
public void submitObject(int id, String text)
|
public void submitObject(int id, String text)
|
||||||
{
|
{
|
||||||
submit("object", id, text);
|
submit("object", id, text);
|
||||||
@@ -65,26 +68,26 @@ public class ExamineClient
|
|||||||
.addPathSegment(Integer.toString(id))
|
.addPathSegment(Integer.toString(id))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.post(RequestBody.create(TEXT, text))
|
.post(RequestBody.create(TEXT, text))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
{
|
{
|
||||||
logger.warn("Error submitting examine", e);
|
log.warn("Error submitting examine", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call call, Response response)
|
public void onResponse(Call call, Response response)
|
||||||
{
|
{
|
||||||
response.close();
|
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.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import javax.inject.Inject;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class FeedClient
|
public class FeedClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FeedClient.class);
|
|
||||||
|
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public FeedClient(OkHttpClient client)
|
|
||||||
{
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FeedResult lookupFeed() throws IOException
|
public FeedResult lookupFeed() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
.addPathSegment("feed.js")
|
.addPathSegment("feed.js")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
@@ -65,7 +58,7 @@ public class FeedClient
|
|||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
logger.debug("Error looking up feed: {}", response);
|
log.debug("Error looking up feed: {}", response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ package net.runelite.http.api.ge;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
@@ -34,15 +35,19 @@ import static net.runelite.http.api.RuneLiteAPI.JSON;
|
|||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class GrandExchangeClient
|
public class GrandExchangeClient
|
||||||
{
|
{
|
||||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||||
|
|
||||||
|
private final OkHttpClient client;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
@Setter
|
@Setter
|
||||||
@@ -69,7 +74,7 @@ public class GrandExchangeClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
|
|||||||
@@ -25,9 +25,10 @@
|
|||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.http.api.hiscore;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.apache.commons.csv.CSVFormat;
|
import org.apache.commons.csv.CSVFormat;
|
||||||
@@ -35,8 +36,11 @@ import org.apache.commons.csv.CSVParser;
|
|||||||
import org.apache.commons.csv.CSVRecord;
|
import org.apache.commons.csv.CSVRecord;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class HiscoreClient
|
public class HiscoreClient
|
||||||
{
|
{
|
||||||
|
private final OkHttpClient client;
|
||||||
|
|
||||||
public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException
|
public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException
|
||||||
{
|
{
|
||||||
return lookup(username, endpoint.getHiscoreURL());
|
return lookup(username, endpoint.getHiscoreURL());
|
||||||
@@ -97,7 +101,7 @@ public class HiscoreClient
|
|||||||
|
|
||||||
String responseStr;
|
String responseStr;
|
||||||
|
|
||||||
try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute())
|
try (Response okresponse = client.newCall(okrequest).execute())
|
||||||
{
|
{
|
||||||
if (!okresponse.isSuccessful())
|
if (!okresponse.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,27 +31,20 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
public class ItemClient
|
public class ItemClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ItemClient.class);
|
|
||||||
|
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public ItemClient(OkHttpClient client)
|
|
||||||
{
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemPrice[] getPrices() throws IOException
|
public ItemPrice[] getPrices() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
@@ -60,7 +53,7 @@ public class ItemClient
|
|||||||
|
|
||||||
HttpUrl url = urlBuilder.build();
|
HttpUrl url = urlBuilder.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
@@ -70,7 +63,7 @@ public class ItemClient
|
|||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
logger.warn("Error looking up prices: {}", response);
|
log.warn("Error looking up prices: {}", response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +85,7 @@ public class ItemClient
|
|||||||
|
|
||||||
HttpUrl url = urlBuilder.build();
|
HttpUrl url = urlBuilder.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
@@ -102,7 +95,7 @@ public class ItemClient
|
|||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
logger.warn("Error looking up item stats: {}", response);
|
log.warn("Error looking up item stats: {}", response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import static net.runelite.http.api.RuneLiteAPI.JSON;
|
|||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -51,6 +52,7 @@ public class LootTrackerClient
|
|||||||
{
|
{
|
||||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||||
|
|
||||||
|
private final OkHttpClient client;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
|
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
|
||||||
@@ -67,7 +69,7 @@ public class LootTrackerClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
@@ -99,7 +101,7 @@ public class LootTrackerClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -134,7 +136,7 @@ public class LootTrackerClient
|
|||||||
.url(builder.build())
|
.url(builder.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
|
|||||||
@@ -28,15 +28,20 @@ import com.google.gson.JsonParseException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
public class OSBGrandExchangeClient
|
public class OSBGrandExchangeClient
|
||||||
{
|
{
|
||||||
|
private final OkHttpClient client;
|
||||||
|
|
||||||
public OSBGrandExchangeResult lookupItem(int itemId) throws IOException
|
public OSBGrandExchangeResult lookupItem(int itemId) throws IOException
|
||||||
{
|
{
|
||||||
final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
@@ -51,7 +56,7 @@ public class OSBGrandExchangeClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (final Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,34 +29,27 @@ import com.google.gson.JsonParseException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import javax.inject.Inject;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class WorldClient
|
public class WorldClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WorldClient.class);
|
|
||||||
|
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public WorldClient(OkHttpClient client)
|
|
||||||
{
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldResult lookupWorlds() throws IOException
|
public WorldResult lookupWorlds() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||||
.addPathSegment("worlds.js")
|
.addPathSegment("worlds.js")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
@@ -66,7 +59,7 @@ public class WorldClient
|
|||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
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");
|
throw new IOException("unsuccessful response looking up worlds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,18 +25,24 @@
|
|||||||
package net.runelite.http.api.xp;
|
package net.runelite.http.api.xp;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class XpClient
|
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)
|
public void update(String username)
|
||||||
{
|
{
|
||||||
@@ -50,19 +56,19 @@ public class XpClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
{
|
{
|
||||||
logger.warn("Error submitting xp track", e);
|
log.warn("Error submitting xp track", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call call, Response response)
|
public void onResponse(Call call, Response response)
|
||||||
{
|
{
|
||||||
response.close();
|
response.close();
|
||||||
logger.debug("Submitted xp track for {}", username);
|
log.debug("Submitted xp track for {}", username);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,20 +30,23 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import static net.runelite.http.api.RuneLiteAPI.JSON;
|
import static net.runelite.http.api.RuneLiteAPI.JSON;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
public class XteaClient
|
public class XteaClient
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(XteaClient.class);
|
private final OkHttpClient client;
|
||||||
|
|
||||||
public void submit(XteaRequest xteaRequest)
|
public void submit(XteaRequest xteaRequest)
|
||||||
{
|
{
|
||||||
@@ -53,19 +56,19 @@ public class XteaClient
|
|||||||
.addPathSegment("xtea")
|
.addPathSegment("xtea")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logger.debug("Built URI: {}", url);
|
log.debug("Built URI: {}", url);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.post(RequestBody.create(JSON, json))
|
.post(RequestBody.create(JSON, json))
|
||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
client.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
{
|
{
|
||||||
logger.warn("unable to submit xtea keys", e);
|
log.warn("unable to submit xtea keys", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,7 +78,7 @@ public class XteaClient
|
|||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
logger.debug("unsuccessful xtea response");
|
log.debug("unsuccessful xtea response");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -96,7 +99,7 @@ public class XteaClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
InputStream in = response.body().byteStream();
|
InputStream in = response.body().byteStream();
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
@@ -120,7 +123,7 @@ public class XteaClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
InputStream in = response.body().byteStream();
|
InputStream in = response.body().byteStream();
|
||||||
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), XteaKey.class);
|
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), XteaKey.class);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.google.common.cache.LoadingCache;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
import net.runelite.http.api.hiscore.HiscoreClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||||
@@ -40,7 +41,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class HiscoreService
|
public class HiscoreService
|
||||||
{
|
{
|
||||||
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
private final HiscoreClient hiscoreClient = new HiscoreClient(RuneLiteAPI.CLIENT);
|
||||||
private final LoadingCache<HiscoreKey, HiscoreResult> hiscoreCache = CacheBuilder.newBuilder()
|
private final LoadingCache<HiscoreKey, HiscoreResult> hiscoreCache = CacheBuilder.newBuilder()
|
||||||
.maximumSize(128)
|
.maximumSize(128)
|
||||||
.expireAfterWrite(1, TimeUnit.MINUTES)
|
.expireAfterWrite(1, TimeUnit.MINUTES)
|
||||||
|
|||||||
@@ -38,23 +38,27 @@ import net.runelite.api.GameState;
|
|||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ClientShutdown;
|
import net.runelite.client.events.ClientShutdown;
|
||||||
import net.runelite.client.util.RunnableExceptionLogger;
|
import net.runelite.client.util.RunnableExceptionLogger;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClientSessionManager
|
public class ClientSessionManager
|
||||||
{
|
{
|
||||||
private final SessionClient sessionClient = new SessionClient();
|
|
||||||
private final ScheduledExecutorService executorService;
|
private final ScheduledExecutorService executorService;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
|
private final SessionClient sessionClient;
|
||||||
|
|
||||||
private ScheduledFuture<?> scheduledFuture;
|
private ScheduledFuture<?> scheduledFuture;
|
||||||
private UUID sessionId;
|
private UUID sessionId;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ClientSessionManager(ScheduledExecutorService executorService, @Nullable Client client)
|
ClientSessionManager(ScheduledExecutorService executorService,
|
||||||
|
@Nullable Client client,
|
||||||
|
OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
this.sessionClient = new SessionClient(okHttpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start()
|
public void start()
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay;
|
|||||||
import net.runelite.client.ui.overlay.tooltip.TooltipOverlay;
|
import net.runelite.client.ui.overlay.tooltip.TooltipOverlay;
|
||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
|
||||||
import net.runelite.client.ws.PartyService;
|
import net.runelite.client.ws.PartyService;
|
||||||
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
import okhttp3.Cache;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -91,6 +94,8 @@ public class RuneLite
|
|||||||
public static final File DEFAULT_SESSION_FILE = new File(RUNELITE_DIR, "session");
|
public static final File DEFAULT_SESSION_FILE = new File(RUNELITE_DIR, "session");
|
||||||
public static final File DEFAULT_CONFIG_FILE = new File(RUNELITE_DIR, "settings.properties");
|
public static final File DEFAULT_CONFIG_FILE = new File(RUNELITE_DIR, "settings.properties");
|
||||||
|
|
||||||
|
private static final int MAX_OKHTTP_CACHE_SIZE = 20 * 1024 * 1024; // 20mb
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static Injector injector;
|
private static Injector injector;
|
||||||
|
|
||||||
@@ -178,6 +183,7 @@ public class RuneLite
|
|||||||
parser.accepts("developer-mode", "Enable developer tools");
|
parser.accepts("developer-mode", "Enable developer tools");
|
||||||
parser.accepts("debug", "Show extra debugging output");
|
parser.accepts("debug", "Show extra debugging output");
|
||||||
parser.accepts("safe-mode", "Disables external plugins and the GPU plugin");
|
parser.accepts("safe-mode", "Disables external plugins and the GPU plugin");
|
||||||
|
parser.accepts("insecure-skip-tls-verification", "Disables TLS verification");
|
||||||
|
|
||||||
final ArgumentAcceptingOptionSpec<File> sessionfile = parser.accepts("sessionfile", "Use a specified session file")
|
final ArgumentAcceptingOptionSpec<File> sessionfile = parser.accepts("sessionfile", "Use a specified session file")
|
||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
@@ -227,12 +233,16 @@ public class RuneLite
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final OkHttpClient okHttpClient = RuneLiteAPI.CLIENT.newBuilder()
|
||||||
|
.cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE))
|
||||||
|
.build();
|
||||||
|
|
||||||
SplashScreen.init();
|
SplashScreen.init();
|
||||||
SplashScreen.stage(0, "Retrieving client", "");
|
SplashScreen.stage(0, "Retrieving client", "");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final ClientLoader clientLoader = new ClientLoader(options.valueOf(updateMode));
|
final ClientLoader clientLoader = new ClientLoader(okHttpClient, options.valueOf(updateMode));
|
||||||
|
|
||||||
new Thread(() ->
|
new Thread(() ->
|
||||||
{
|
{
|
||||||
@@ -265,6 +275,7 @@ public class RuneLite
|
|||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
|
||||||
injector = Guice.createInjector(new RuneLiteModule(
|
injector = Guice.createInjector(new RuneLiteModule(
|
||||||
|
okHttpClient,
|
||||||
clientLoader,
|
clientLoader,
|
||||||
developerMode,
|
developerMode,
|
||||||
options.has("safe-mode"),
|
options.has("safe-mode"),
|
||||||
|
|||||||
@@ -50,15 +50,13 @@ import net.runelite.client.plugins.PluginManager;
|
|||||||
import net.runelite.client.task.Scheduler;
|
import net.runelite.client.task.Scheduler;
|
||||||
import net.runelite.client.util.DeferredEventBus;
|
import net.runelite.client.util.DeferredEventBus;
|
||||||
import net.runelite.client.util.ExecutorServiceExceptionLogger;
|
import net.runelite.client.util.ExecutorServiceExceptionLogger;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.chat.ChatClient;
|
||||||
import okhttp3.Cache;
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class RuneLiteModule extends AbstractModule
|
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 Supplier<Applet> clientLoader;
|
||||||
private final boolean developerMode;
|
private final boolean developerMode;
|
||||||
private final boolean safeMode;
|
private final boolean safeMode;
|
||||||
@@ -73,9 +71,7 @@ public class RuneLiteModule extends AbstractModule
|
|||||||
bind(File.class).annotatedWith(Names.named("sessionfile")).toInstance(sessionfile);
|
bind(File.class).annotatedWith(Names.named("sessionfile")).toInstance(sessionfile);
|
||||||
bind(File.class).annotatedWith(Names.named("config")).toInstance(config);
|
bind(File.class).annotatedWith(Names.named("config")).toInstance(config);
|
||||||
bind(ScheduledExecutorService.class).toInstance(new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()));
|
bind(ScheduledExecutorService.class).toInstance(new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()));
|
||||||
bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT.newBuilder()
|
bind(OkHttpClient.class).toInstance(okHttpClient);
|
||||||
.cache(new Cache(new File(RuneLite.CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE))
|
|
||||||
.build());
|
|
||||||
bind(MenuManager.class);
|
bind(MenuManager.class);
|
||||||
bind(ChatMessageManager.class);
|
bind(ChatMessageManager.class);
|
||||||
bind(ItemManager.class);
|
bind(ItemManager.class);
|
||||||
@@ -120,4 +116,11 @@ public class RuneLiteModule extends AbstractModule
|
|||||||
{
|
{
|
||||||
return configManager.getConfig(ChatColorConfig.class);
|
return configManager.getConfig(ChatColorConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
ChatClient provideChatClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new ChatClient(okHttpClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,15 +29,20 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
class SessionClient
|
class SessionClient
|
||||||
{
|
{
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
|
||||||
UUID open() throws IOException
|
UUID open() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
||||||
@@ -48,7 +53,7 @@ class SessionClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
ResponseBody body = response.body();
|
ResponseBody body = response.body();
|
||||||
|
|
||||||
@@ -74,7 +79,7 @@ class SessionClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -94,6 +99,6 @@ class SessionClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.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.AccountClient;
|
||||||
import net.runelite.http.api.account.OAuthResponse;
|
import net.runelite.http.api.account.OAuthResponse;
|
||||||
import net.runelite.http.api.ws.messages.LoginResponse;
|
import net.runelite.http.api.ws.messages.LoginResponse;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -59,18 +60,21 @@ public class SessionManager
|
|||||||
private final ConfigManager configManager;
|
private final ConfigManager configManager;
|
||||||
private final WSClient wsClient;
|
private final WSClient wsClient;
|
||||||
private final File sessionFile;
|
private final File sessionFile;
|
||||||
|
private final AccountClient accountClient;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SessionManager(
|
private SessionManager(
|
||||||
@Named("sessionfile") File sessionfile,
|
@Named("sessionfile") File sessionfile,
|
||||||
ConfigManager configManager,
|
ConfigManager configManager,
|
||||||
EventBus eventBus,
|
EventBus eventBus,
|
||||||
WSClient wsClient)
|
WSClient wsClient,
|
||||||
|
OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
this.configManager = configManager;
|
this.configManager = configManager;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.wsClient = wsClient;
|
this.wsClient = wsClient;
|
||||||
this.sessionFile = sessionfile;
|
this.sessionFile = sessionfile;
|
||||||
|
this.accountClient = new AccountClient(okHttpClient);
|
||||||
|
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
}
|
}
|
||||||
@@ -98,7 +102,7 @@ public class SessionManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if session is still valid
|
// Check if session is still valid
|
||||||
AccountClient accountClient = new AccountClient(session.getUuid());
|
accountClient.setUuid(session.getUuid());
|
||||||
if (!accountClient.sessionCheck())
|
if (!accountClient.sessionCheck())
|
||||||
{
|
{
|
||||||
log.debug("Loaded session {} is invalid", session.getUuid());
|
log.debug("Loaded session {} is invalid", session.getUuid());
|
||||||
@@ -169,10 +173,10 @@ public class SessionManager
|
|||||||
|
|
||||||
log.debug("Logging out of account {}", accountSession.getUsername());
|
log.debug("Logging out of account {}", accountSession.getUsername());
|
||||||
|
|
||||||
AccountClient client = new AccountClient(accountSession.getUuid());
|
accountClient.setUuid(accountSession.getUuid());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.logout();
|
accountClient.logout();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
@@ -191,13 +195,13 @@ public class SessionManager
|
|||||||
{
|
{
|
||||||
// If a session is already open, use that id. Otherwise generate a new id.
|
// If a session is already open, use that id. Otherwise generate a new id.
|
||||||
UUID uuid = wsClient.getSessionId() != null ? wsClient.getSessionId() : UUID.randomUUID();
|
UUID uuid = wsClient.getSessionId() != null ? wsClient.getSessionId() : UUID.randomUUID();
|
||||||
AccountClient loginClient = new AccountClient(uuid);
|
accountClient.setUuid(uuid);
|
||||||
|
|
||||||
final OAuthResponse login;
|
final OAuthResponse login;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
login = loginClient.login();
|
login = accountClient.login();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ import net.runelite.client.util.ColorUtil;
|
|||||||
import net.runelite.http.api.config.ConfigClient;
|
import net.runelite.http.api.config.ConfigClient;
|
||||||
import net.runelite.http.api.config.ConfigEntry;
|
import net.runelite.http.api.config.ConfigEntry;
|
||||||
import net.runelite.http.api.config.Configuration;
|
import net.runelite.http.api.config.Configuration;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -85,10 +86,9 @@ public class ConfigManager
|
|||||||
{
|
{
|
||||||
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
||||||
|
|
||||||
@Inject
|
private final File settingsFileInput;
|
||||||
EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
private final ScheduledExecutorService executor;
|
|
||||||
|
|
||||||
private AccountSession session;
|
private AccountSession session;
|
||||||
private ConfigClient client;
|
private ConfigClient client;
|
||||||
@@ -97,18 +97,20 @@ public class ConfigManager
|
|||||||
private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this);
|
private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this);
|
||||||
private final Properties properties = new Properties();
|
private final Properties properties = new Properties();
|
||||||
private final Map<String, String> pendingChanges = new HashMap<>();
|
private final Map<String, String> pendingChanges = new HashMap<>();
|
||||||
private final File settingsFileInput;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ConfigManager(
|
public ConfigManager(
|
||||||
@Named("config") File config,
|
@Named("config") File config,
|
||||||
ScheduledExecutorService scheduledExecutorService)
|
ScheduledExecutorService scheduledExecutorService,
|
||||||
|
EventBus eventBus,
|
||||||
|
OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
this.executor = scheduledExecutorService;
|
|
||||||
this.settingsFileInput = config;
|
this.settingsFileInput = config;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
this.propertiesFile = getPropertiesFile();
|
this.propertiesFile = getPropertiesFile();
|
||||||
|
|
||||||
executor.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
|
scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void switchSession(AccountSession session)
|
public final void switchSession(AccountSession session)
|
||||||
@@ -124,7 +126,7 @@ public class ConfigManager
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.client = new ConfigClient(session.getUuid());
|
this.client = new ConfigClient(okHttpClient, session.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.propertiesFile = getPropertiesFile();
|
this.propertiesFile = getPropertiesFile();
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ import net.runelite.client.ui.SplashScreen;
|
|||||||
import net.runelite.client.util.CountingInputStream;
|
import net.runelite.client.util.CountingInputStream;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.client.util.VerificationException;
|
import net.runelite.client.util.VerificationException;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@@ -95,6 +95,9 @@ public class ExternalPluginManager
|
|||||||
@Inject
|
@Inject
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
public void loadExternalPlugins() throws PluginInstantiationException
|
public void loadExternalPlugins() throws PluginInstantiationException
|
||||||
{
|
{
|
||||||
refreshPlugins();
|
refreshPlugins();
|
||||||
@@ -208,7 +211,7 @@ public class ExternalPluginManager
|
|||||||
.addPathSegment(manifest.getCommit() + ".jar")
|
.addPathSegment(manifest.getCommit() + ".jar")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response res = RuneLiteAPI.CLIENT.newCall(new Request.Builder().url(url).build()).execute())
|
try (Response res = okHttpClient.newCall(new Request.Builder().url(url).build()).execute())
|
||||||
{
|
{
|
||||||
int fdownloaded = downloaded;
|
int fdownloaded = downloaded;
|
||||||
downloaded += manifest.getSize();
|
downloaded += manifest.getSize();
|
||||||
|
|||||||
@@ -33,11 +33,10 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
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.HiscoreClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class HiscoreManager
|
public class HiscoreManager
|
||||||
@@ -53,12 +52,13 @@ public class HiscoreManager
|
|||||||
static final HiscoreResult EMPTY = new HiscoreResult();
|
static final HiscoreResult EMPTY = new HiscoreResult();
|
||||||
static final HiscoreResult NONE = new HiscoreResult();
|
static final HiscoreResult NONE = new HiscoreResult();
|
||||||
|
|
||||||
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
|
||||||
private final LoadingCache<HiscoreKey, HiscoreResult> hiscoreCache;
|
private final LoadingCache<HiscoreKey, HiscoreResult> hiscoreCache;
|
||||||
|
private final HiscoreClient hiscoreClient;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public HiscoreManager(Client client, ScheduledExecutorService executor, ClientThread clientThread)
|
public HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
|
hiscoreClient = new HiscoreClient(okHttpClient);
|
||||||
hiscoreCache = CacheBuilder.newBuilder()
|
hiscoreCache = CacheBuilder.newBuilder()
|
||||||
.maximumSize(128L)
|
.maximumSize(128L)
|
||||||
.expireAfterWrite(1, TimeUnit.HOURS)
|
.expireAfterWrite(1, TimeUnit.HOURS)
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import net.runelite.client.util.AsyncBufferedImage;
|
|||||||
import net.runelite.http.api.item.ItemClient;
|
import net.runelite.http.api.item.ItemClient;
|
||||||
import net.runelite.http.api.item.ItemPrice;
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
import net.runelite.http.api.item.ItemStats;
|
import net.runelite.http.api.item.ItemStats;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -82,10 +83,9 @@ public class ItemManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final ScheduledExecutorService scheduledExecutorService;
|
|
||||||
private final ClientThread clientThread;
|
private final ClientThread clientThread;
|
||||||
|
|
||||||
private final ItemClient itemClient;
|
private final ItemClient itemClient;
|
||||||
|
|
||||||
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
|
||||||
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
|
||||||
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
|
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
|
||||||
@@ -162,13 +162,12 @@ public class ItemManager
|
|||||||
build();
|
build();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ItemManager(Client client, ScheduledExecutorService executor, ClientThread clientThread,
|
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
|
||||||
ItemClient itemClient)
|
OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.scheduledExecutorService = executor;
|
|
||||||
this.clientThread = clientThread;
|
this.clientThread = clientThread;
|
||||||
this.itemClient = itemClient;
|
this.itemClient = new ItemClient(okHttpClient);
|
||||||
|
|
||||||
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
||||||
scheduledExecutorService.submit(this::loadStats);
|
scheduledExecutorService.submit(this::loadStats);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import net.runelite.client.util.RunnableExceptionLogger;
|
|||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldClient;
|
import net.runelite.http.api.worlds.WorldClient;
|
||||||
import net.runelite.http.api.worlds.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -59,12 +60,12 @@ public class WorldService
|
|||||||
private WorldResult worlds;
|
private WorldResult worlds;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, WorldClient worldClient,
|
private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, OkHttpClient okHttpClient,
|
||||||
EventBus eventBus)
|
EventBus eventBus)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.scheduledExecutorService = scheduledExecutorService;
|
this.scheduledExecutorService = scheduledExecutorService;
|
||||||
this.worldClient = worldClient;
|
this.worldClient = new WorldClient(okHttpClient);
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
scheduledExecutorService.scheduleWithFixedDelay(RunnableExceptionLogger.wrap(this::tick), 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES);
|
scheduledExecutorService.scheduleWithFixedDelay(RunnableExceptionLogger.wrap(this::tick), 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES);
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ import net.runelite.http.api.hiscore.HiscoreSkill;
|
|||||||
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
import net.runelite.http.api.hiscore.Skill;
|
||||||
import net.runelite.http.api.item.ItemPrice;
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.text.WordUtils;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
@@ -128,8 +129,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1;
|
static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1;
|
||||||
|
|
||||||
private final ChatClient chatClient = new ChatClient();
|
|
||||||
|
|
||||||
private boolean bossLogLoaded;
|
private boolean bossLogLoaded;
|
||||||
private boolean advLogLoaded;
|
private boolean advLogLoaded;
|
||||||
private boolean scrollInterfaceLoaded;
|
private boolean scrollInterfaceLoaded;
|
||||||
@@ -168,6 +167,9 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private HiscoreClient hiscoreClient;
|
private HiscoreClient hiscoreClient;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ChatClient chatClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startUp()
|
public void startUp()
|
||||||
{
|
{
|
||||||
@@ -213,6 +215,12 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
return configManager.getConfig(ChatCommandsConfig.class);
|
return configManager.getConfig(ChatCommandsConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
HiscoreClient provideHiscoreClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new HiscoreClient(okHttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
private void setKc(String boss, int killcount)
|
private void setKc(String boss, int killcount)
|
||||||
{
|
{
|
||||||
configManager.setConfiguration("killcount." + client.getUsername().toLowerCase(),
|
configManager.setConfiguration("killcount." + client.getUsername().toLowerCase(),
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import net.runelite.api.GameState;
|
|||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.WorldType;
|
import net.runelite.api.WorldType;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.StatChanged;
|
import net.runelite.api.events.StatChanged;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
@@ -54,6 +53,7 @@ import net.runelite.client.discord.events.DiscordJoinGame;
|
|||||||
import net.runelite.client.discord.events.DiscordJoinRequest;
|
import net.runelite.client.discord.events.DiscordJoinRequest;
|
||||||
import net.runelite.client.discord.events.DiscordReady;
|
import net.runelite.client.discord.events.DiscordReady;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.events.PartyChanged;
|
import net.runelite.client.events.PartyChanged;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -65,12 +65,12 @@ import net.runelite.client.util.LinkBrowser;
|
|||||||
import net.runelite.client.ws.PartyMember;
|
import net.runelite.client.ws.PartyMember;
|
||||||
import net.runelite.client.ws.PartyService;
|
import net.runelite.client.ws.PartyService;
|
||||||
import net.runelite.client.ws.WSClient;
|
import net.runelite.client.ws.WSClient;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.ws.messages.party.UserJoin;
|
import net.runelite.http.api.ws.messages.party.UserJoin;
|
||||||
import net.runelite.http.api.ws.messages.party.UserPart;
|
import net.runelite.http.api.ws.messages.party.UserPart;
|
||||||
import net.runelite.http.api.ws.messages.party.UserSync;
|
import net.runelite.http.api.ws.messages.party.UserSync;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@@ -103,6 +103,9 @@ public class DiscordPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private WSClient wsClient;
|
private WSClient wsClient;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private Map<Skill, Integer> skillExp = new HashMap<>();
|
private Map<Skill, Integer> skillExp = new HashMap<>();
|
||||||
private NavigationButton discordButton;
|
private NavigationButton discordButton;
|
||||||
private boolean loginFlag;
|
private boolean loginFlag;
|
||||||
@@ -273,7 +276,7 @@ public class DiscordPlugin extends Plugin
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
okHttpClient.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.examine;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.inject.Provides;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
@@ -58,6 +59,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.client.util.QuantityFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.examine.ExamineClient;
|
import net.runelite.http.api.examine.ExamineClient;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submits examine info to the api
|
* Submits examine info to the api
|
||||||
@@ -91,6 +93,12 @@ public class ExaminePlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ChatMessageManager chatMessageManager;
|
private ChatMessageManager chatMessageManager;
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
ExamineClient provideExamineClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new ExamineClient(okHttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged event)
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import java.time.Instant;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
@@ -55,17 +57,18 @@ import net.runelite.client.ui.FontManager;
|
|||||||
import net.runelite.client.ui.PluginPanel;
|
import net.runelite.client.ui.PluginPanel;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
import net.runelite.client.util.LinkBrowser;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.feed.FeedItem;
|
import net.runelite.http.api.feed.FeedItem;
|
||||||
import net.runelite.http.api.feed.FeedItemType;
|
import net.runelite.http.api.feed.FeedItemType;
|
||||||
import net.runelite.http.api.feed.FeedResult;
|
import net.runelite.http.api.feed.FeedResult;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Singleton
|
||||||
class FeedPanel extends PluginPanel
|
class FeedPanel extends PluginPanel
|
||||||
{
|
{
|
||||||
private static final ImageIcon RUNELITE_ICON;
|
private static final ImageIcon RUNELITE_ICON;
|
||||||
@@ -104,12 +107,15 @@ class FeedPanel extends PluginPanel
|
|||||||
|
|
||||||
private final FeedConfig config;
|
private final FeedConfig config;
|
||||||
private final Supplier<FeedResult> feedSupplier;
|
private final Supplier<FeedResult> feedSupplier;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
|
||||||
FeedPanel(FeedConfig config, Supplier<FeedResult> feedSupplier)
|
@Inject
|
||||||
|
FeedPanel(FeedConfig config, Supplier<FeedResult> feedSupplier, OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
super(true);
|
super(true);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.feedSupplier = feedSupplier;
|
this.feedSupplier = feedSupplier;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
|
||||||
setBorder(new EmptyBorder(10, 10, 10, 10));
|
setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
setBackground(ColorScheme.DARK_GRAY_COLOR);
|
||||||
@@ -158,7 +164,7 @@ class FeedPanel extends PluginPanel
|
|||||||
.url(item.getAvatar())
|
.url(item.getAvatar())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
okHttpClient.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
package net.runelite.client.plugins.feed;
|
package net.runelite.client.plugins.feed;
|
||||||
|
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@@ -34,9 +36,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
@@ -45,6 +47,7 @@ import net.runelite.client.ui.NavigationButton;
|
|||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.http.api.feed.FeedClient;
|
import net.runelite.http.api.feed.FeedClient;
|
||||||
import net.runelite.http.api.feed.FeedResult;
|
import net.runelite.http.api.feed.FeedResult;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "News Feed",
|
name = "News Feed",
|
||||||
@@ -70,7 +73,7 @@ public class FeedPlugin extends Plugin
|
|||||||
private FeedPanel feedPanel;
|
private FeedPanel feedPanel;
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
|
|
||||||
private Supplier<FeedResult> feedSupplier = Suppliers.memoizeWithExpiration(() ->
|
private final Supplier<FeedResult> feedSupplier = Suppliers.memoizeWithExpiration(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -83,10 +86,19 @@ public class FeedPlugin extends Plugin
|
|||||||
return null;
|
return null;
|
||||||
}, 10, TimeUnit.MINUTES);
|
}, 10, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configure(Binder binder)
|
||||||
|
{
|
||||||
|
// CHECKSTYLE:OFF
|
||||||
|
binder.bind(new TypeLiteral<Supplier<FeedResult>>(){})
|
||||||
|
.toInstance(feedSupplier);
|
||||||
|
// CHECKSTYLE:ON
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
feedPanel = new FeedPanel(config, feedSupplier);
|
feedPanel = injector.getInstance(FeedPanel.class);
|
||||||
|
|
||||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "icon.png");
|
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "icon.png");
|
||||||
|
|
||||||
@@ -136,4 +148,10 @@ public class FeedPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return configManager.getConfig(FeedConfig.class);
|
return configManager.getConfig(FeedConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
FeedClient provideFeedClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new FeedClient(okHttpClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ import net.runelite.http.api.item.ItemStats;
|
|||||||
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
|
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
|
||||||
import net.runelite.http.api.osbuddy.OSBGrandExchangeResult;
|
import net.runelite.http.api.osbuddy.OSBGrandExchangeResult;
|
||||||
import net.runelite.http.api.worlds.WorldType;
|
import net.runelite.http.api.worlds.WorldType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||||
import org.apache.commons.text.similarity.FuzzyScore;
|
import org.apache.commons.text.similarity.FuzzyScore;
|
||||||
|
|
||||||
@@ -119,7 +120,6 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
private static final int GE_SLOTS = 8;
|
private static final int GE_SLOTS = 8;
|
||||||
private static final int OFFER_CONTAINER_ITEM = 21;
|
private static final int OFFER_CONTAINER_ITEM = 21;
|
||||||
private static final int OFFER_DEFAULT_ITEM_ID = 6512;
|
private static final int OFFER_DEFAULT_ITEM_ID = 6512;
|
||||||
private static final OSBGrandExchangeClient CLIENT = new OSBGrandExchangeClient();
|
|
||||||
private static final String OSB_GE_TEXT = "<br>OSBuddy Actively traded price: ";
|
private static final String OSB_GE_TEXT = "<br>OSBuddy Actively traded price: ";
|
||||||
|
|
||||||
private static final String BUY_LIMIT_GE_TEXT = "<br>Buy limit: ";
|
private static final String BUY_LIMIT_GE_TEXT = "<br>Buy limit: ";
|
||||||
@@ -190,6 +190,9 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
private boolean loginBurstGeUpdates;
|
private boolean loginBurstGeUpdates;
|
||||||
private static String machineUuid;
|
private static String machineUuid;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private OSBGrandExchangeClient osbGrandExchangeClient;
|
||||||
|
|
||||||
private boolean wasFuzzySearch;
|
private boolean wasFuzzySearch;
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -291,6 +294,18 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
return configManager.getConfig(GrandExchangeConfig.class);
|
return configManager.getConfig(GrandExchangeConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
OSBGrandExchangeClient provideOsbGrandExchangeClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new OSBGrandExchangeClient(okHttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
GrandExchangeClient provideGrandExchangeClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new GrandExchangeClient(okHttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
@@ -902,7 +917,7 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final OSBGrandExchangeResult result = CLIENT.lookupItem(itemId);
|
final OSBGrandExchangeResult result = osbGrandExchangeClient.lookupItem(itemId);
|
||||||
if (result != null && result.getOverall_average() > 0)
|
if (result != null && result.getOverall_average() > 0)
|
||||||
{
|
{
|
||||||
osbGrandExchangeResult = result;
|
osbGrandExchangeResult = result;
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ import net.runelite.http.api.hiscore.HiscoreSkill;
|
|||||||
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
|
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkillType;
|
import net.runelite.http.api.hiscore.HiscoreSkillType;
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
import net.runelite.http.api.hiscore.Skill;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -118,15 +119,11 @@ public class HiscorePanel extends PluginPanel
|
|||||||
HiscoreEndpoint.NORMAL, HiscoreEndpoint.IRONMAN, HiscoreEndpoint.HARDCORE_IRONMAN, HiscoreEndpoint.ULTIMATE_IRONMAN, HiscoreEndpoint.DEADMAN, HiscoreEndpoint.TOURNAMENT
|
HiscoreEndpoint.NORMAL, HiscoreEndpoint.IRONMAN, HiscoreEndpoint.HARDCORE_IRONMAN, HiscoreEndpoint.ULTIMATE_IRONMAN, HiscoreEndpoint.DEADMAN, HiscoreEndpoint.TOURNAMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
@Inject
|
private final ScheduledExecutorService executor;
|
||||||
ScheduledExecutorService executor;
|
private final Client client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Nullable
|
|
||||||
private Client client;
|
|
||||||
|
|
||||||
private final HiscoreConfig config;
|
private final HiscoreConfig config;
|
||||||
private final NameAutocompleter nameAutocompleter;
|
private final NameAutocompleter nameAutocompleter;
|
||||||
|
private final HiscoreClient hiscoreClient;
|
||||||
|
|
||||||
private final IconTextField searchBar;
|
private final IconTextField searchBar;
|
||||||
|
|
||||||
@@ -136,10 +133,6 @@ public class HiscorePanel extends PluginPanel
|
|||||||
/* Container of all the selectable endpoints (ironman, deadman, etc) */
|
/* Container of all the selectable endpoints (ironman, deadman, etc) */
|
||||||
private final MaterialTabGroup tabGroup;
|
private final MaterialTabGroup tabGroup;
|
||||||
|
|
||||||
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
|
||||||
|
|
||||||
private HiscoreResult result;
|
|
||||||
|
|
||||||
/* The currently selected endpoint */
|
/* The currently selected endpoint */
|
||||||
private HiscoreEndpoint selectedEndPoint;
|
private HiscoreEndpoint selectedEndPoint;
|
||||||
|
|
||||||
@@ -147,11 +140,14 @@ public class HiscorePanel extends PluginPanel
|
|||||||
private boolean loading = false;
|
private boolean loading = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public HiscorePanel(HiscoreConfig config, NameAutocompleter nameAutocompleter)
|
public HiscorePanel(ScheduledExecutorService scheduledExecutorService, @Nullable Client client,
|
||||||
|
HiscoreConfig config, NameAutocompleter nameAutocompleter, OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
super();
|
this.executor = scheduledExecutorService;
|
||||||
|
this.client = client;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.nameAutocompleter = nameAutocompleter;
|
this.nameAutocompleter = nameAutocompleter;
|
||||||
|
this.hiscoreClient = new HiscoreClient(okHttpClient);
|
||||||
|
|
||||||
// The layout seems to be ignoring the top margin and only gives it
|
// The layout seems to be ignoring the top margin and only gives it
|
||||||
// a 2-3 pixel margin, so I set the value to 18 to compensate
|
// a 2-3 pixel margin, so I set the value to 18 to compensate
|
||||||
@@ -405,6 +401,7 @@ public class HiscorePanel extends PluginPanel
|
|||||||
selectedEndPoint = HiscoreEndpoint.NORMAL;
|
selectedEndPoint = HiscoreEndpoint.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HiscoreResult result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log.debug("Hiscore endpoint " + selectedEndPoint.name() + " selected");
|
log.debug("Hiscore endpoint " + selectedEndPoint.name() + " selected");
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ import net.runelite.http.api.loottracker.LootAggregate;
|
|||||||
import net.runelite.http.api.loottracker.LootRecord;
|
import net.runelite.http.api.loottracker.LootRecord;
|
||||||
import net.runelite.http.api.loottracker.LootRecordType;
|
import net.runelite.http.api.loottracker.LootRecordType;
|
||||||
import net.runelite.http.api.loottracker.LootTrackerClient;
|
import net.runelite.http.api.loottracker.LootTrackerClient;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.text.WordUtils;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
@@ -234,6 +235,9 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private LootManager lootManager;
|
private LootManager lootManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private LootTrackerPanel panel;
|
private LootTrackerPanel panel;
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -293,7 +297,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
AccountSession accountSession = sessionManager.getAccountSession();
|
AccountSession accountSession = sessionManager.getAccountSession();
|
||||||
if (accountSession.getUuid() != null)
|
if (accountSession.getUuid() != null)
|
||||||
{
|
{
|
||||||
lootTrackerClient = new LootTrackerClient(accountSession.getUuid());
|
lootTrackerClient = new LootTrackerClient(okHttpClient, accountSession.getUuid());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -341,7 +345,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
AccountSession accountSession = sessionManager.getAccountSession();
|
AccountSession accountSession = sessionManager.getAccountSession();
|
||||||
if (accountSession != null)
|
if (accountSession != null)
|
||||||
{
|
{
|
||||||
lootTrackerClient = new LootTrackerClient(accountSession.getUuid());
|
lootTrackerClient = new LootTrackerClient(okHttpClient, accountSession.getUuid());
|
||||||
|
|
||||||
clientThread.invokeLater(() ->
|
clientThread.invokeLater(() ->
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ import net.runelite.client.plugins.raids.solver.Layout;
|
|||||||
import net.runelite.client.plugins.raids.solver.LayoutSolver;
|
import net.runelite.client.plugins.raids.solver.LayoutSolver;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.util.QuantityFormatter;
|
|
||||||
import net.runelite.client.util.HotkeyListener;
|
import net.runelite.client.util.HotkeyListener;
|
||||||
import net.runelite.client.util.ImageCapture;
|
import net.runelite.client.util.ImageCapture;
|
||||||
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import static net.runelite.client.util.Text.sanitize;
|
import static net.runelite.client.util.Text.sanitize;
|
||||||
import net.runelite.client.ws.PartyMember;
|
import net.runelite.client.ws.PartyMember;
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
SlayerConfig getConfig(ConfigManager configManager)
|
SlayerConfig provideSlayerConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
return configManager.getConfig(SlayerConfig.class);
|
return configManager.getConfig(SlayerConfig.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ import net.runelite.client.callback.ClientThread;
|
|||||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
||||||
import net.runelite.client.game.chatbox.ChatboxTextInput;
|
import net.runelite.client.game.chatbox.ChatboxTextInput;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
import net.runelite.client.util.LinkBrowser;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput
|
|||||||
private static final int PREDICTION_DEBOUNCE_DELAY_MS = 200;
|
private static final int PREDICTION_DEBOUNCE_DELAY_MS = 200;
|
||||||
|
|
||||||
private final ChatboxPanelManager chatboxPanelManager;
|
private final ChatboxPanelManager chatboxPanelManager;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
private final Gson gson = new Gson();
|
private final Gson gson = new Gson();
|
||||||
|
|
||||||
private Future<?> runningRequest = null;
|
private Future<?> runningRequest = null;
|
||||||
@@ -76,10 +77,12 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WikiSearchChatboxTextInput(ChatboxPanelManager chatboxPanelManager, ClientThread clientThread,
|
public WikiSearchChatboxTextInput(ChatboxPanelManager chatboxPanelManager, ClientThread clientThread,
|
||||||
ScheduledExecutorService scheduledExecutorService, @Named("developerMode") final boolean developerMode)
|
ScheduledExecutorService scheduledExecutorService, @Named("developerMode") final boolean developerMode,
|
||||||
|
OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
super(chatboxPanelManager, clientThread);
|
super(chatboxPanelManager, clientThread);
|
||||||
this.chatboxPanelManager = chatboxPanelManager;
|
this.chatboxPanelManager = chatboxPanelManager;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
|
||||||
lines(1);
|
lines(1);
|
||||||
prompt("OSRS Wiki Search");
|
prompt("OSRS Wiki Search");
|
||||||
@@ -122,7 +125,7 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(req).enqueue(new Callback()
|
okHttpClient.newCall(req).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import net.runelite.client.ui.overlay.OverlayManager;
|
|||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.xp.XpClient;
|
import net.runelite.http.api.xp.XpClient;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "XP Tracker",
|
name = "XP Tracker",
|
||||||
@@ -116,6 +117,9 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private XpClient xpClient;
|
||||||
|
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
@Setter(AccessLevel.PACKAGE)
|
@Setter(AccessLevel.PACKAGE)
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -127,7 +131,6 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
private long lastXp = 0;
|
private long lastXp = 0;
|
||||||
private boolean initializeTracker;
|
private boolean initializeTracker;
|
||||||
|
|
||||||
private final XpClient xpClient = new XpClient();
|
|
||||||
private final XpState xpState = new XpState();
|
private final XpState xpState = new XpState();
|
||||||
private final XpPauseState xpPauseState = new XpPauseState();
|
private final XpPauseState xpPauseState = new XpPauseState();
|
||||||
|
|
||||||
@@ -137,6 +140,12 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
return configManager.getConfig(XpTrackerConfig.class);
|
return configManager.getConfig(XpTrackerConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
XpClient provideXpClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new XpClient(okHttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Binder binder)
|
public void configure(Binder binder)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.xpupdater;
|
package net.runelite.client.plugins.xpupdater;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import com.google.inject.Provides;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
@@ -40,11 +40,11 @@ import net.runelite.client.config.ConfigManager;
|
|||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.FormBody;
|
import okhttp3.FormBody;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -66,13 +66,16 @@ public class XpUpdaterPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private XpUpdaterConfig config;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private String lastUsername;
|
private String lastUsername;
|
||||||
private boolean fetchXp;
|
private boolean fetchXp;
|
||||||
private long lastXp;
|
private long lastXp;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private XpUpdaterConfig config;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
XpUpdaterConfig getConfig(ConfigManager configManager)
|
XpUpdaterConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -191,9 +194,9 @@ public class XpUpdaterPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendRequest(String platform, Request request)
|
private void sendRequest(String platform, Request request)
|
||||||
{
|
{
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
okHttpClient.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e)
|
public void onFailure(Call call, IOException e)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.xtea;
|
package net.runelite.client.plugins.xtea;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -37,6 +38,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.http.api.xtea.XteaClient;
|
import net.runelite.http.api.xtea.XteaClient;
|
||||||
import net.runelite.http.api.xtea.XteaKey;
|
import net.runelite.http.api.xtea.XteaKey;
|
||||||
import net.runelite.http.api.xtea.XteaRequest;
|
import net.runelite.http.api.xtea.XteaRequest;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Xtea",
|
name = "Xtea",
|
||||||
@@ -45,13 +47,20 @@ import net.runelite.http.api.xtea.XteaRequest;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class XteaPlugin extends Plugin
|
public class XteaPlugin extends Plugin
|
||||||
{
|
{
|
||||||
private final XteaClient xteaClient = new XteaClient();
|
|
||||||
|
|
||||||
private final Set<Integer> sentRegions = new HashSet<>();
|
private final Set<Integer> sentRegions = new HashSet<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private XteaClient xteaClient;
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
XteaClient provideXteaClient(OkHttpClient okHttpClient)
|
||||||
|
{
|
||||||
|
return new XteaClient(okHttpClient);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,18 +28,18 @@ package net.runelite.client.rs;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import lombok.AllArgsConstructor;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
class ClientConfigLoader
|
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()
|
final Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
@@ -47,7 +47,7 @@ class ClientConfigLoader
|
|||||||
|
|
||||||
final RSConfig config = new RSConfig();
|
final RSConfig config = new RSConfig();
|
||||||
|
|
||||||
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (final Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ import net.runelite.client.ui.FatalErrorDialog;
|
|||||||
import net.runelite.client.ui.SplashScreen;
|
import net.runelite.client.ui.SplashScreen;
|
||||||
import net.runelite.client.util.CountingInputStream;
|
import net.runelite.client.util.CountingInputStream;
|
||||||
import net.runelite.client.util.VerificationException;
|
import net.runelite.client.util.VerificationException;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@@ -83,14 +83,19 @@ public class ClientLoader implements Supplier<Applet>
|
|||||||
private static File VANILLA_CACHE = new File(RuneLite.CACHE_DIR, "vanilla.cache");
|
private static File VANILLA_CACHE = new File(RuneLite.CACHE_DIR, "vanilla.cache");
|
||||||
private static File PATCHED_CACHE = new File(RuneLite.CACHE_DIR, "patched.cache");
|
private static File PATCHED_CACHE = new File(RuneLite.CACHE_DIR, "patched.cache");
|
||||||
|
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
private final ClientConfigLoader clientConfigLoader;
|
||||||
private ClientUpdateCheckMode updateCheckMode;
|
private ClientUpdateCheckMode updateCheckMode;
|
||||||
private Object client = null;
|
private final WorldSupplier worldSupplier;
|
||||||
|
|
||||||
private WorldSupplier worldSupplier = new WorldSupplier();
|
private Object client;
|
||||||
|
|
||||||
public ClientLoader(ClientUpdateCheckMode updateCheckMode)
|
public ClientLoader(OkHttpClient okHttpClient, ClientUpdateCheckMode updateCheckMode)
|
||||||
{
|
{
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.clientConfigLoader = new ClientConfigLoader(okHttpClient);
|
||||||
this.updateCheckMode = updateCheckMode;
|
this.updateCheckMode = updateCheckMode;
|
||||||
|
this.worldSupplier = new WorldSupplier(okHttpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -187,7 +192,7 @@ public class ClientLoader implements Supplier<Applet>
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RSConfig config = ClientConfigLoader.fetch(url);
|
RSConfig config = clientConfigLoader.fetch(url);
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(config.getCodeBase()) || Strings.isNullOrEmpty(config.getInitialJar()) || Strings.isNullOrEmpty(config.getInitialClass()))
|
if (Strings.isNullOrEmpty(config.getCodeBase()) || Strings.isNullOrEmpty(config.getInitialJar()) || Strings.isNullOrEmpty(config.getInitialClass()))
|
||||||
{
|
{
|
||||||
@@ -221,7 +226,7 @@ public class ClientLoader implements Supplier<Applet>
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private RSConfig downloadFallbackConfig() throws IOException
|
private RSConfig downloadFallbackConfig() throws IOException
|
||||||
{
|
{
|
||||||
RSConfig backupConfig = ClientConfigLoader.fetch(HttpUrl.parse(RuneLiteProperties.getJavConfigBackup()));
|
RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.parse(RuneLiteProperties.getJavConfigBackup()));
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar()) || Strings.isNullOrEmpty(backupConfig.getInitialClass()))
|
if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar()) || Strings.isNullOrEmpty(backupConfig.getInitialClass()))
|
||||||
{
|
{
|
||||||
@@ -298,7 +303,7 @@ public class ClientLoader implements Supplier<Applet>
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
// Its important to not close the response manually - this should be the only close or
|
// Its important to not close the response manually - this should be the only close or
|
||||||
// try-with-resources on this stream or it's children
|
// try-with-resources on this stream or it's children
|
||||||
|
|||||||
@@ -33,15 +33,18 @@ import java.util.Queue;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldClient;
|
import net.runelite.http.api.worlds.WorldClient;
|
||||||
import net.runelite.http.api.worlds.WorldType;
|
import net.runelite.http.api.worlds.WorldType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
class WorldSupplier implements Supplier<World>
|
class WorldSupplier implements Supplier<World>
|
||||||
{
|
{
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
private final Random random = new Random(System.nanoTime());
|
private final Random random = new Random(System.nanoTime());
|
||||||
private Queue<World> worlds = new ArrayDeque<>();
|
private Queue<World> worlds = new ArrayDeque<>();
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ class WorldSupplier implements Supplier<World>
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<World> newWorlds = new WorldClient(RuneLiteAPI.CLIENT)
|
List<World> newWorlds = new WorldClient(okHttpClient)
|
||||||
.lookupWorlds()
|
.lookupWorlds()
|
||||||
.getWorlds()
|
.getWorlds()
|
||||||
.stream()
|
.stream()
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import okhttp3.Call;
|
|||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -76,6 +77,9 @@ public class ImageCapture
|
|||||||
@Inject
|
@Inject
|
||||||
private Notifier notifier;
|
private Notifier notifier;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a screenshot of the client window to the screenshot folder as a PNG,
|
* Saves a screenshot of the client window to the screenshot folder as a PNG,
|
||||||
* and optionally uploads it to an image-hosting service.
|
* and optionally uploads it to an image-hosting service.
|
||||||
@@ -197,7 +201,7 @@ public class ImageCapture
|
|||||||
.post(RequestBody.create(JSON, json))
|
.post(RequestBody.create(JSON, json))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
okHttpClient.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException ex)
|
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.WebsocketMessage;
|
||||||
import net.runelite.http.api.ws.messages.Handshake;
|
import net.runelite.http.api.ws.messages.Handshake;
|
||||||
import net.runelite.http.api.ws.messages.party.PartyMessage;
|
import net.runelite.http.api.ws.messages.party.PartyMessage;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.WebSocket;
|
import okhttp3.WebSocket;
|
||||||
@@ -50,6 +51,7 @@ import okhttp3.WebSocketListener;
|
|||||||
public class WSClient extends WebSocketListener implements AutoCloseable
|
public class WSClient extends WebSocketListener implements AutoCloseable
|
||||||
{
|
{
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
private final Collection<Class<? extends WebsocketMessage>> messages = new HashSet<>();
|
private final Collection<Class<? extends WebsocketMessage>> messages = new HashSet<>();
|
||||||
|
|
||||||
private volatile Gson gson;
|
private volatile Gson gson;
|
||||||
@@ -58,9 +60,10 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
private WebSocket webSocket;
|
private WebSocket webSocket;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WSClient(EventBus eventBus)
|
private WSClient(EventBus eventBus, OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
this.gson = WebsocketGsonFactory.build(WebsocketGsonFactory.factory(messages));
|
this.gson = WebsocketGsonFactory.build(WebsocketGsonFactory.factory(messages));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +104,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
.url(RuneLiteAPI.getWsEndpoint())
|
.url(RuneLiteAPI.getWsEndpoint())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
webSocket = RuneLiteAPI.CLIENT.newWebSocket(request, this);
|
webSocket = okHttpClient.newWebSocket(request, this);
|
||||||
|
|
||||||
Handshake handshake = new Handshake();
|
Handshake handshake = new Handshake();
|
||||||
handshake.setSession(sessionId);
|
handshake.setSession(sessionId);
|
||||||
|
|||||||
@@ -51,13 +51,18 @@ import net.runelite.client.RuneLiteModule;
|
|||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
@@ -76,14 +81,18 @@ public class PluginManagerTest
|
|||||||
@Bind
|
@Bind
|
||||||
public Client client;
|
public Client client;
|
||||||
|
|
||||||
private Set<Class> pluginClasses;
|
private Set<Class<?>> pluginClasses;
|
||||||
private Set<Class> configClasses;
|
private Set<Class<?>> configClasses;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws IOException
|
public void before() throws IOException
|
||||||
{
|
{
|
||||||
|
OkHttpClient okHttpClient = mock(OkHttpClient.class);
|
||||||
|
when(okHttpClient.newCall(any(Request.class)))
|
||||||
|
.thenThrow(new RuntimeException("in plugin manager test"));
|
||||||
|
|
||||||
Injector injector = Guice.createInjector(Modules
|
Injector injector = Guice.createInjector(Modules
|
||||||
.override(new RuneLiteModule(() -> null, true, false,
|
.override(new RuneLiteModule(okHttpClient, () -> null, true, false,
|
||||||
RuneLite.DEFAULT_SESSION_FILE,
|
RuneLite.DEFAULT_SESSION_FILE,
|
||||||
RuneLite.DEFAULT_CONFIG_FILE))
|
RuneLite.DEFAULT_CONFIG_FILE))
|
||||||
.with(BoundFieldModule.of(this)));
|
.with(BoundFieldModule.of(this)));
|
||||||
@@ -119,7 +128,7 @@ public class PluginManagerTest
|
|||||||
pluginManager.loadCorePlugins();
|
pluginManager.loadCorePlugins();
|
||||||
Collection<Plugin> plugins = pluginManager.getPlugins();
|
Collection<Plugin> plugins = pluginManager.getPlugins();
|
||||||
long expected = pluginClasses.stream()
|
long expected = pluginClasses.stream()
|
||||||
.map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class))
|
.map(cl -> cl.getAnnotation(PluginDescriptor.class))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(PluginDescriptor::loadWhenOutdated)
|
.filter(PluginDescriptor::loadWhenOutdated)
|
||||||
.count();
|
.count();
|
||||||
@@ -134,7 +143,7 @@ public class PluginManagerTest
|
|||||||
plugins.forEach(eventBus::register);
|
plugins.forEach(eventBus::register);
|
||||||
|
|
||||||
expected = pluginClasses.stream()
|
expected = pluginClasses.stream()
|
||||||
.map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class))
|
.map(cl -> cl.getAnnotation(PluginDescriptor.class))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(pd -> !pd.developerPlugin())
|
.filter(pd -> !pd.developerPlugin())
|
||||||
.count();
|
.count();
|
||||||
@@ -146,16 +155,13 @@ public class PluginManagerTest
|
|||||||
{
|
{
|
||||||
List<Module> modules = new ArrayList<>();
|
List<Module> modules = new ArrayList<>();
|
||||||
modules.add(new GraphvizModule());
|
modules.add(new GraphvizModule());
|
||||||
modules.add(new RuneLiteModule(() -> null, true, false,
|
modules.add(new RuneLiteModule(mock(OkHttpClient.class), () -> null, true, false,
|
||||||
RuneLite.DEFAULT_SESSION_FILE,
|
RuneLite.DEFAULT_SESSION_FILE,
|
||||||
RuneLite.DEFAULT_CONFIG_FILE));
|
RuneLite.DEFAULT_CONFIG_FILE));
|
||||||
|
|
||||||
PluginManager pluginManager = new PluginManager(true, false, null, null, null, null, null);
|
PluginManager pluginManager = new PluginManager(true, false, null, null, null, null, null);
|
||||||
pluginManager.loadCorePlugins();
|
pluginManager.loadCorePlugins();
|
||||||
for (Plugin p : pluginManager.getPlugins())
|
modules.addAll(pluginManager.getPlugins());
|
||||||
{
|
|
||||||
modules.add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = folder.newFile();
|
File file = folder.newFile();
|
||||||
try (PrintWriter out = new PrintWriter(file, "UTF-8"))
|
try (PrintWriter out = new PrintWriter(file, "UTF-8"))
|
||||||
@@ -171,7 +177,7 @@ public class PluginManagerTest
|
|||||||
@Test
|
@Test
|
||||||
public void ensureNoDuplicateConfigKeyNames()
|
public void ensureNoDuplicateConfigKeyNames()
|
||||||
{
|
{
|
||||||
for (final Class clazz : configClasses)
|
for (final Class<?> clazz : configClasses)
|
||||||
{
|
{
|
||||||
final Set<String> configKeyNames = new HashSet<>();
|
final Set<String> configKeyNames = new HashSet<>();
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import net.runelite.client.chat.ChatCommandManager;
|
|||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
|
import net.runelite.http.api.chat.ChatClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
import net.runelite.http.api.hiscore.HiscoreClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
import net.runelite.http.api.hiscore.HiscoreSkill;
|
||||||
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
||||||
@@ -103,6 +104,10 @@ public class ChatCommandsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
ChatMessageManager chatMessageManager;
|
ChatMessageManager chatMessageManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ChatClient chatClient;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
ChatCommandsConfig chatCommandsConfig;
|
ChatCommandsConfig chatCommandsConfig;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import static net.runelite.client.plugins.grandexchange.GrandExchangePlugin.find
|
|||||||
import static net.runelite.http.api.RuneLiteAPI.GSON;
|
import static net.runelite.http.api.RuneLiteAPI.GSON;
|
||||||
import net.runelite.http.api.ge.GrandExchangeClient;
|
import net.runelite.http.api.ge.GrandExchangeClient;
|
||||||
import net.runelite.http.api.ge.GrandExchangeTrade;
|
import net.runelite.http.api.ge.GrandExchangeTrade;
|
||||||
|
import net.runelite.http.api.osbuddy.OSBGrandExchangeClient;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -108,6 +109,10 @@ public class GrandExchangePluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
private GrandExchangeClient grandExchangeClient;
|
private GrandExchangeClient grandExchangeClient;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
private OSBGrandExchangeClient osbGrandExchangeClient;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.hiscore;
|
package net.runelite.client.plugins.hiscore;
|
||||||
|
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import static net.runelite.client.plugins.hiscore.HiscorePanel.formatLevel;
|
import static net.runelite.client.plugins.hiscore.HiscorePanel.formatLevel;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -34,7 +36,7 @@ public class HiscorePanelTest
|
|||||||
@Test
|
@Test
|
||||||
public void testConstructor()
|
public void testConstructor()
|
||||||
{
|
{
|
||||||
new HiscorePanel(mock(HiscoreConfig.class), mock(NameAutocompleter.class));
|
new HiscorePanel(mock(ScheduledExecutorService.class), null, mock(HiscoreConfig.class), mock(NameAutocompleter.class), mock(OkHttpClient.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import net.runelite.client.game.ItemManager;
|
|||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.util.ImageCapture;
|
import net.runelite.client.util.ImageCapture;
|
||||||
import net.runelite.client.ws.PartyService;
|
import net.runelite.client.ws.PartyService;
|
||||||
|
import net.runelite.http.api.chat.ChatClient;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -93,6 +94,10 @@ public class RaidsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
Notifier notifier;
|
Notifier notifier;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ChatClient chatClient;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
RaidsConfig raidsConfig;
|
RaidsConfig raidsConfig;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import net.runelite.client.game.NPCManager;
|
|||||||
import net.runelite.client.game.SkillIconManager;
|
import net.runelite.client.game.SkillIconManager;
|
||||||
import net.runelite.client.ui.ClientToolbar;
|
import net.runelite.client.ui.ClientToolbar;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
|
import net.runelite.http.api.xp.XpClient;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -70,6 +71,10 @@ public class XpTrackerPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
private XpTrackerConfig xpTrackerConfig;
|
private XpTrackerConfig xpTrackerConfig;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
private XpClient xpClient;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
private NPCManager npcManager;
|
private NPCManager npcManager;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.google.common.io.CharStreams;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.mockwebserver.MockResponse;
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -63,7 +64,7 @@ public class ClientConfigLoaderTest
|
|||||||
@Test
|
@Test
|
||||||
public void testFetch() throws IOException
|
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());
|
assertEquals("http://oldschool1.runescape.com/", config.getCodeBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user