Move http-api clients to rl-client
This commit is contained in:
@@ -32,10 +32,10 @@ import java.io.InputStream;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import lombok.Getter;
|
||||||
import net.runelite.http.api.gson.ColorTypeAdapter;
|
import net.runelite.http.api.gson.ColorTypeAdapter;
|
||||||
import net.runelite.http.api.gson.InstantTypeAdapter;
|
|
||||||
import net.runelite.http.api.gson.IllegalReflectionExclusion;
|
import net.runelite.http.api.gson.IllegalReflectionExclusion;
|
||||||
import okhttp3.HttpUrl;
|
import net.runelite.http.api.gson.InstantTypeAdapter;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
@@ -56,10 +56,8 @@ public class RuneLiteAPI
|
|||||||
public static final MediaType JSON = MediaType.parse("application/json");
|
public static final MediaType JSON = MediaType.parse("application/json");
|
||||||
public static String userAgent;
|
public static String userAgent;
|
||||||
|
|
||||||
private static final String BASE = "https://api.runelite.net";
|
|
||||||
private static final String WSBASE = "https://api.runelite.net/ws";
|
|
||||||
private static final String STATICBASE = "https://static.runelite.net";
|
|
||||||
private static final Properties properties = new Properties();
|
private static final Properties properties = new Properties();
|
||||||
|
@Getter
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -118,63 +116,4 @@ public class RuneLiteAPI
|
|||||||
|
|
||||||
GSON = gsonBuilder.create();
|
GSON = gsonBuilder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpUrl getSessionBase()
|
|
||||||
{
|
|
||||||
final String prop = System.getProperty("runelite.session.url");
|
|
||||||
|
|
||||||
if (prop != null && !prop.isEmpty())
|
|
||||||
{
|
|
||||||
return HttpUrl.parse(prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HttpUrl.parse(BASE + "/session");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HttpUrl getApiBase()
|
|
||||||
{
|
|
||||||
final String prop = System.getProperty("runelite.http-service.url");
|
|
||||||
|
|
||||||
if (prop != null && !prop.isEmpty())
|
|
||||||
{
|
|
||||||
return HttpUrl.parse(prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HttpUrl.parse(BASE + "/runelite-" + getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HttpUrl getStaticBase()
|
|
||||||
{
|
|
||||||
final String prop = System.getProperty("runelite.static.url");
|
|
||||||
|
|
||||||
if (prop != null && !prop.isEmpty())
|
|
||||||
{
|
|
||||||
return HttpUrl.parse(prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HttpUrl.parse(STATICBASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HttpUrl getWsEndpoint()
|
|
||||||
{
|
|
||||||
final String prop = System.getProperty("runelite.ws.url");
|
|
||||||
|
|
||||||
if (prop != null && !prop.isEmpty())
|
|
||||||
{
|
|
||||||
return HttpUrl.parse(prop);
|
|
||||||
}
|
|
||||||
|
|
||||||
return HttpUrl.parse(WSBASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion()
|
|
||||||
{
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setVersion(String version)
|
|
||||||
{
|
|
||||||
RuneLiteAPI.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ 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
|
||||||
@@ -54,11 +53,11 @@ public class ClientSessionManager
|
|||||||
@Inject
|
@Inject
|
||||||
ClientSessionManager(ScheduledExecutorService executorService,
|
ClientSessionManager(ScheduledExecutorService executorService,
|
||||||
@Nullable Client client,
|
@Nullable Client client,
|
||||||
OkHttpClient okHttpClient)
|
SessionClient sessionClient)
|
||||||
{
|
{
|
||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.sessionClient = new SessionClient(okHttpClient);
|
this.sessionClient = sessionClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start()
|
public void start()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client;
|
package net.runelite.client;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
@@ -35,6 +36,7 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -53,7 +55,7 @@ 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.RuneLiteAPI;
|
||||||
import net.runelite.http.api.chat.ChatClient;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -129,9 +131,34 @@ public class RuneLiteModule extends AbstractModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Named("runelite.api.base")
|
||||||
ChatClient provideChatClient(OkHttpClient okHttpClient)
|
HttpUrl provideApiBase(@Named("runelite.api.base") String s)
|
||||||
{
|
{
|
||||||
return new ChatClient(okHttpClient);
|
final String prop = System.getProperty("runelite.http-service.url");
|
||||||
|
return HttpUrl.get(Strings.isNullOrEmpty(prop) ? s : prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("runelite.session")
|
||||||
|
HttpUrl provideSession(@Named("runelite.session") String s)
|
||||||
|
{
|
||||||
|
final String prop = System.getProperty("runelite.session.url");
|
||||||
|
return HttpUrl.get(Strings.isNullOrEmpty(prop) ? s : prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("runelite.static.base")
|
||||||
|
HttpUrl provideStaticBase(@Named("runelite.static.base") String s)
|
||||||
|
{
|
||||||
|
final String prop = System.getProperty("runelite.static.url");
|
||||||
|
return HttpUrl.get(Strings.isNullOrEmpty(prop) ? s : prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("runelite.ws")
|
||||||
|
HttpUrl provideWs(@Named("runelite.ws") String s)
|
||||||
|
{
|
||||||
|
final String prop = System.getProperty("runelite.ws.url");
|
||||||
|
return HttpUrl.get(Strings.isNullOrEmpty(prop) ? s : prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class RuneLiteProperties
|
|||||||
private static final String JAV_CONFIG_BACKUP = "runelite.jav_config_backup";
|
private static final String JAV_CONFIG_BACKUP = "runelite.jav_config_backup";
|
||||||
private static final String PLUGINHUB_BASE = "runelite.pluginhub.url";
|
private static final String PLUGINHUB_BASE = "runelite.pluginhub.url";
|
||||||
private static final String PLUGINHUB_VERSION = "runelite.pluginhub.version";
|
private static final String PLUGINHUB_VERSION = "runelite.pluginhub.version";
|
||||||
|
private static final String API_BASE = "runelite.api.base";
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private static final Properties properties = new Properties();
|
private static final Properties properties = new Properties();
|
||||||
@@ -112,4 +113,9 @@ public class RuneLiteProperties
|
|||||||
String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION));
|
String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION));
|
||||||
return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version);
|
return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getApiBase()
|
||||||
|
{
|
||||||
|
return properties.getProperty(API_BASE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,8 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.AllArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
@@ -39,14 +40,21 @@ import okhttp3.RequestBody;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
class SessionClient
|
class SessionClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient okHttpClient;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl sessionUrl;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SessionClient(OkHttpClient client, @Named("runelite.session") HttpUrl sessionUrl)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.sessionUrl = sessionUrl;
|
||||||
|
}
|
||||||
|
|
||||||
UUID open() throws IOException
|
UUID open() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
HttpUrl url = sessionUrl.newBuilder()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
@@ -54,7 +62,7 @@ class SessionClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = okHttpClient.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
ResponseBody body = response.body();
|
ResponseBody body = response.body();
|
||||||
|
|
||||||
@@ -69,7 +77,7 @@ class SessionClient
|
|||||||
|
|
||||||
void ping(UUID uuid, boolean loggedIn) throws IOException
|
void ping(UUID uuid, boolean loggedIn) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
HttpUrl url = sessionUrl.newBuilder()
|
||||||
.addPathSegment("ping")
|
.addPathSegment("ping")
|
||||||
.addQueryParameter("session", uuid.toString())
|
.addQueryParameter("session", uuid.toString())
|
||||||
.addQueryParameter("logged-in", String.valueOf(loggedIn))
|
.addQueryParameter("logged-in", String.valueOf(loggedIn))
|
||||||
@@ -80,7 +88,7 @@ class SessionClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = okHttpClient.newCall(request).execute())
|
try (Response response = client.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -91,7 +99,7 @@ class SessionClient
|
|||||||
|
|
||||||
void delete(UUID uuid) throws IOException
|
void delete(UUID uuid) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder()
|
HttpUrl url = sessionUrl.newBuilder()
|
||||||
.addQueryParameter("session", uuid.toString())
|
.addQueryParameter("session", uuid.toString())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -100,6 +108,6 @@ class SessionClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
okHttpClient.newCall(request).execute().close();
|
client.newCall(request).execute().close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.account;
|
package net.runelite.client.account;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -30,29 +30,36 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
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;
|
||||||
|
import net.runelite.http.api.account.OAuthResponse;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class AccountClient
|
public class AccountClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
|
@Setter
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
public void setUuid(UUID uuid)
|
@Inject
|
||||||
|
private AccountClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
{
|
{
|
||||||
this.uuid = uuid;
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuthResponse login() throws IOException
|
public OAuthResponse login() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("account")
|
.addPathSegment("account")
|
||||||
.addPathSegment("login")
|
.addPathSegment("login")
|
||||||
.addQueryParameter("uuid", uuid.toString())
|
.addQueryParameter("uuid", uuid.toString())
|
||||||
@@ -77,7 +84,7 @@ public class AccountClient
|
|||||||
|
|
||||||
public void logout() throws IOException
|
public void logout() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("account")
|
.addPathSegment("account")
|
||||||
.addPathSegment("logout")
|
.addPathSegment("logout")
|
||||||
.build();
|
.build();
|
||||||
@@ -97,7 +104,7 @@ public class AccountClient
|
|||||||
|
|
||||||
public boolean sessionCheck()
|
public boolean sessionCheck()
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("account")
|
.addPathSegment("account")
|
||||||
.addPathSegment("session-check")
|
.addPathSegment("session-check")
|
||||||
.build();
|
.build();
|
||||||
@@ -47,10 +47,8 @@ import net.runelite.client.events.SessionClose;
|
|||||||
import net.runelite.client.events.SessionOpen;
|
import net.runelite.client.events.SessionOpen;
|
||||||
import net.runelite.client.util.LinkBrowser;
|
import net.runelite.client.util.LinkBrowser;
|
||||||
import net.runelite.client.ws.WSClient;
|
import net.runelite.client.ws.WSClient;
|
||||||
import net.runelite.http.api.account.AccountClient;
|
|
||||||
import net.runelite.http.api.account.OAuthResponse;
|
import net.runelite.http.api.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
|
||||||
@@ -72,14 +70,14 @@ public class SessionManager
|
|||||||
ConfigManager configManager,
|
ConfigManager configManager,
|
||||||
EventBus eventBus,
|
EventBus eventBus,
|
||||||
WSClient wsClient,
|
WSClient wsClient,
|
||||||
OkHttpClient okHttpClient,
|
AccountClient accountClient,
|
||||||
Gson gson)
|
Gson gson)
|
||||||
{
|
{
|
||||||
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);
|
this.accountClient = accountClient;
|
||||||
this.gson = gson;
|
this.gson = gson;
|
||||||
|
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.chat;
|
package net.runelite.client.chat;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@@ -32,22 +32,33 @@ import java.io.InputStreamReader;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.AllArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
import net.runelite.http.api.chat.Duels;
|
||||||
|
import net.runelite.http.api.chat.LayoutRoom;
|
||||||
|
import net.runelite.http.api.chat.Task;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
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;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ChatClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
}
|
||||||
|
|
||||||
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 = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("kc")
|
.addPathSegment("kc")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -68,7 +79,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public int getKc(String username, String boss) throws IOException
|
public int getKc(String username, String boss) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("kc")
|
.addPathSegment("kc")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -91,7 +102,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitQp(String username, int qp) throws IOException
|
public boolean submitQp(String username, int qp) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("qp")
|
.addPathSegment("qp")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -111,7 +122,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public int getQp(String username) throws IOException
|
public int getQp(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("qp")
|
.addPathSegment("qp")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -133,7 +144,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitTask(String username, String task, int amount, int initialAmount, String location) throws IOException
|
public boolean submitTask(String username, String task, int amount, int initialAmount, String location) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("task")
|
.addPathSegment("task")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -156,7 +167,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public Task getTask(String username) throws IOException
|
public Task getTask(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("task")
|
.addPathSegment("task")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -184,7 +195,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitPb(String username, String boss, double pb) throws IOException
|
public boolean submitPb(String username, String boss, double pb) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("pb")
|
.addPathSegment("pb")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -205,7 +216,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public double getPb(String username, String boss) throws IOException
|
public double getPb(String username, String boss) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("pb")
|
.addPathSegment("pb")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -228,7 +239,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitGc(String username, int gc) throws IOException
|
public boolean submitGc(String username, int gc) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("gc")
|
.addPathSegment("gc")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -248,7 +259,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public int getGc(String username) throws IOException
|
public int getGc(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("gc")
|
.addPathSegment("gc")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -270,7 +281,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitDuels(String username, int wins, int losses, int winningStreak, int losingStreak) throws IOException
|
public boolean submitDuels(String username, int wins, int losses, int winningStreak, int losingStreak) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("duels")
|
.addPathSegment("duels")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -293,7 +304,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public Duels getDuels(String username) throws IOException
|
public Duels getDuels(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("duels")
|
.addPathSegment("duels")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -321,7 +332,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitLayout(String username, LayoutRoom[] rooms) throws IOException
|
public boolean submitLayout(String username, LayoutRoom[] rooms) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("layout")
|
.addPathSegment("layout")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -340,7 +351,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public LayoutRoom[] getLayout(String username) throws IOException
|
public LayoutRoom[] getLayout(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("layout")
|
.addPathSegment("layout")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -368,7 +379,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public boolean submitPetList(String username, Collection<Integer> petList) throws IOException
|
public boolean submitPetList(String username, Collection<Integer> petList) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("pets")
|
.addPathSegment("pets")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -387,7 +398,7 @@ public class ChatClient
|
|||||||
|
|
||||||
public Set<Integer> getPetList(String username) throws IOException
|
public Set<Integer> getPetList(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("chat")
|
.addPathSegment("chat")
|
||||||
.addPathSegment("pets")
|
.addPathSegment("pets")
|
||||||
.addQueryParameter("name", username)
|
.addQueryParameter("name", username)
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.config;
|
package net.runelite.client.config;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
@@ -32,9 +32,12 @@ import java.io.InputStreamReader;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import lombok.AllArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
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;
|
||||||
|
import net.runelite.http.api.config.Configuration;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
@@ -44,7 +47,6 @@ import okhttp3.Request;
|
|||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ConfigClient
|
public class ConfigClient
|
||||||
{
|
{
|
||||||
@@ -52,11 +54,21 @@ public class ConfigClient
|
|||||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||||
|
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
private final UUID uuid;
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private UUID uuid;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConfigClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
}
|
||||||
|
|
||||||
public Configuration get() throws IOException
|
public Configuration get() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("config")
|
.addPathSegment("config")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -82,7 +94,7 @@ public class ConfigClient
|
|||||||
{
|
{
|
||||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
|
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("config")
|
.addPathSegment("config")
|
||||||
.addPathSegment(key)
|
.addPathSegment(key)
|
||||||
.build();
|
.build();
|
||||||
@@ -120,7 +132,7 @@ public class ConfigClient
|
|||||||
{
|
{
|
||||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
|
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("config")
|
.addPathSegment("config")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -173,7 +185,7 @@ public class ConfigClient
|
|||||||
{
|
{
|
||||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
|
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("config")
|
.addPathSegment("config")
|
||||||
.addPathSegment(key)
|
.addPathSegment(key)
|
||||||
.build();
|
.build();
|
||||||
@@ -72,6 +72,7 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@@ -92,10 +93,8 @@ import net.runelite.client.events.ClientShutdown;
|
|||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.events.RuneScapeProfileChanged;
|
import net.runelite.client.events.RuneScapeProfileChanged;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
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
|
||||||
@@ -116,11 +115,11 @@ public class ConfigManager
|
|||||||
|
|
||||||
private final File settingsFileInput;
|
private final File settingsFileInput;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final OkHttpClient okHttpClient;
|
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
|
@Nonnull
|
||||||
|
private final ConfigClient configClient;
|
||||||
|
|
||||||
private AccountSession session;
|
private AccountSession session;
|
||||||
private ConfigClient configClient;
|
|
||||||
private File propertiesFile;
|
private File propertiesFile;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -140,16 +139,16 @@ public class ConfigManager
|
|||||||
@Named("config") File config,
|
@Named("config") File config,
|
||||||
ScheduledExecutorService scheduledExecutorService,
|
ScheduledExecutorService scheduledExecutorService,
|
||||||
EventBus eventBus,
|
EventBus eventBus,
|
||||||
OkHttpClient okHttpClient,
|
|
||||||
@Nullable Client client,
|
@Nullable Client client,
|
||||||
Gson gson)
|
Gson gson,
|
||||||
|
ConfigClient configClient)
|
||||||
{
|
{
|
||||||
this.settingsFileInput = config;
|
this.settingsFileInput = config;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.okHttpClient = okHttpClient;
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.propertiesFile = getPropertiesFile();
|
this.propertiesFile = getPropertiesFile();
|
||||||
this.gson = gson;
|
this.gson = gson;
|
||||||
|
this.configClient = configClient;
|
||||||
|
|
||||||
scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 5 * 60, TimeUnit.SECONDS);
|
scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 5 * 60, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
@@ -167,12 +166,12 @@ public class ConfigManager
|
|||||||
if (session == null)
|
if (session == null)
|
||||||
{
|
{
|
||||||
this.session = null;
|
this.session = null;
|
||||||
this.configClient = null;
|
configClient.setUuid(null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.configClient = new ConfigClient(okHttpClient, session.getUuid());
|
configClient.setUuid(session.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.propertiesFile = getPropertiesFile();
|
this.propertiesFile = getPropertiesFile();
|
||||||
@@ -201,7 +200,7 @@ public class ConfigManager
|
|||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
if (configClient == null)
|
if (session == null)
|
||||||
{
|
{
|
||||||
loadFromFile();
|
loadFromFile();
|
||||||
return;
|
return;
|
||||||
@@ -909,7 +908,7 @@ public class ConfigManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configClient != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
Configuration patch = new Configuration(pendingChanges.entrySet().stream()
|
Configuration patch = new Configuration(pendingChanges.entrySet().stream()
|
||||||
.map(e -> new ConfigEntry(e.getKey(), e.getValue()))
|
.map(e -> new ConfigEntry(e.getKey(), e.getValue()))
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.RuneLiteProperties;
|
import net.runelite.client.RuneLiteProperties;
|
||||||
import net.runelite.client.util.VerificationException;
|
import net.runelite.client.util.VerificationException;
|
||||||
@@ -62,12 +63,17 @@ public class ExternalPluginClient
|
|||||||
{
|
{
|
||||||
private final OkHttpClient okHttpClient;
|
private final OkHttpClient okHttpClient;
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ExternalPluginClient(OkHttpClient okHttpClient, Gson gson)
|
private ExternalPluginClient(OkHttpClient okHttpClient,
|
||||||
|
Gson gson,
|
||||||
|
@Named("runelite.api.base") HttpUrl apiBase
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.okHttpClient = okHttpClient;
|
this.okHttpClient = okHttpClient;
|
||||||
this.gson = gson;
|
this.gson = gson;
|
||||||
|
this.apiBase = apiBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExternalPluginManifest> downloadManifest() throws IOException, VerificationException
|
public List<ExternalPluginManifest> downloadManifest() throws IOException, VerificationException
|
||||||
@@ -153,7 +159,7 @@ public class ExternalPluginClient
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("pluginhub")
|
.addPathSegment("pluginhub")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -181,7 +187,7 @@ public class ExternalPluginClient
|
|||||||
|
|
||||||
public Map<String, Integer> getPluginCounts() throws IOException
|
public Map<String, Integer> getPluginCounts() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase()
|
HttpUrl url = apiBase
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addPathSegments("pluginhub")
|
.addPathSegments("pluginhub")
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.item;
|
package net.runelite.client.game;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@@ -32,23 +32,37 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.AllArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
|
import net.runelite.http.api.item.ItemStats;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
|
||||||
public class ItemClient
|
public class ItemClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase, staticBase;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ItemClient(OkHttpClient client,
|
||||||
|
@Named("runelite.api.base") HttpUrl apiBase,
|
||||||
|
@Named("runelite.static.base") HttpUrl staticBase
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
this.staticBase = staticBase;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemPrice[] getPrices() throws IOException
|
public ItemPrice[] getPrices() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl.Builder urlBuilder = apiBase.newBuilder()
|
||||||
.addPathSegment("item")
|
.addPathSegment("item")
|
||||||
.addPathSegment("prices.js");
|
.addPathSegment("prices.js");
|
||||||
|
|
||||||
@@ -79,7 +93,7 @@ public class ItemClient
|
|||||||
|
|
||||||
public Map<Integer, ItemStats> getStats() throws IOException
|
public Map<Integer, ItemStats> getStats() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl.Builder urlBuilder = RuneLiteAPI.getStaticBase().newBuilder()
|
HttpUrl.Builder urlBuilder = staticBase.newBuilder()
|
||||||
.addPathSegment("item")
|
.addPathSegment("item")
|
||||||
// TODO: Change this to stats.min.json later after release is undeployed
|
// TODO: Change this to stats.min.json later after release is undeployed
|
||||||
.addPathSegment("stats.ids.min.json");
|
.addPathSegment("stats.ids.min.json");
|
||||||
@@ -55,10 +55,8 @@ import net.runelite.api.SpritePixels;
|
|||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.util.AsyncBufferedImage;
|
import net.runelite.client.util.AsyncBufferedImage;
|
||||||
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
|
||||||
@@ -167,11 +165,11 @@ public class ItemManager
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
|
public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread,
|
||||||
OkHttpClient okHttpClient, RuneLiteConfig runeLiteConfig)
|
ItemClient itemClient, RuneLiteConfig runeLiteConfig)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.clientThread = clientThread;
|
this.clientThread = clientThread;
|
||||||
this.itemClient = new ItemClient(okHttpClient);
|
this.itemClient = itemClient;
|
||||||
this.runeLiteConfig = runeLiteConfig;
|
this.runeLiteConfig = runeLiteConfig;
|
||||||
|
|
||||||
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES);
|
||||||
|
|||||||
@@ -32,21 +32,18 @@ import javax.annotation.Nullable;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.npc.NpcInfo;
|
|
||||||
import net.runelite.http.api.npc.NpcInfoClient;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NPCManager
|
public class NPCManager
|
||||||
{
|
{
|
||||||
private final OkHttpClient okHttpClient;
|
private final NpcInfoClient npcInfoClient;
|
||||||
private Map<Integer, NpcInfo> npcMap = Collections.emptyMap();
|
private Map<Integer, NpcInfo> npcMap = Collections.emptyMap();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NPCManager(OkHttpClient okHttpClient, ScheduledExecutorService scheduledExecutorService)
|
private NPCManager(NpcInfoClient npcInfoClient, ScheduledExecutorService scheduledExecutorService)
|
||||||
{
|
{
|
||||||
this.okHttpClient = okHttpClient;
|
this.npcInfoClient = npcInfoClient;
|
||||||
scheduledExecutorService.execute(this::loadNpcs);
|
scheduledExecutorService.execute(this::loadNpcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +64,7 @@ public class NPCManager
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
npcMap = new NpcInfoClient(okHttpClient).getNpcs();
|
npcMap = npcInfoClient.getNpcs();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.npc;
|
package net.runelite.client.game;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.npc;
|
package net.runelite.client.game;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@@ -32,7 +32,8 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Value;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
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;
|
||||||
@@ -41,14 +42,21 @@ import okhttp3.Request;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Value
|
|
||||||
public class NpcInfoClient
|
public class NpcInfoClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl staticBase;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private NpcInfoClient(OkHttpClient client, @Named("runelite.static.base") HttpUrl staticBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.staticBase = staticBase;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<Integer, NpcInfo> getNpcs() throws IOException
|
public Map<Integer, NpcInfo> getNpcs() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl.Builder urlBuilder = RuneLiteAPI.getStaticBase().newBuilder()
|
HttpUrl.Builder urlBuilder = staticBase.newBuilder()
|
||||||
.addPathSegment("npcs")
|
.addPathSegment("npcs")
|
||||||
.addPathSegment("npcs.min.json");
|
.addPathSegment("npcs.min.json");
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.worlds;
|
package net.runelite.client.game;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -33,6 +33,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
@@ -43,10 +44,11 @@ import okhttp3.Response;
|
|||||||
public class WorldClient
|
public class WorldClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
public WorldResult lookupWorlds() throws IOException
|
public WorldResult lookupWorlds() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("worlds.js")
|
.addPathSegment("worlds.js")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -41,8 +42,8 @@ import net.runelite.client.eventbus.EventBus;
|
|||||||
import net.runelite.client.events.WorldsFetch;
|
import net.runelite.client.events.WorldsFetch;
|
||||||
import net.runelite.client.util.RunnableExceptionLogger;
|
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.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -61,11 +62,11 @@ public class WorldService
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, OkHttpClient okHttpClient,
|
private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, OkHttpClient okHttpClient,
|
||||||
EventBus eventBus)
|
@Named("runelite.api.base") HttpUrl apiBase, EventBus eventBus)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.scheduledExecutorService = scheduledExecutorService;
|
this.scheduledExecutorService = scheduledExecutorService;
|
||||||
this.worldClient = new WorldClient(okHttpClient);
|
this.worldClient = new WorldClient(okHttpClient, apiBase);
|
||||||
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);
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID;
|
|||||||
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
|
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageBuilder;
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
@@ -93,7 +94,6 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
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.chat.ChatClient;
|
|
||||||
import net.runelite.http.api.chat.Duels;
|
import net.runelite.http.api.chat.Duels;
|
||||||
import net.runelite.http.api.item.ItemPrice;
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|||||||
@@ -22,30 +22,39 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.feed;
|
package net.runelite.client.plugins.feed;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
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 java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import lombok.RequiredArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
import net.runelite.http.api.feed.FeedResult;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class FeedClient
|
public class FeedClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private FeedClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
}
|
||||||
|
|
||||||
public FeedResult lookupFeed() throws IOException
|
public FeedResult lookupFeed() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("feed.js")
|
.addPathSegment("feed.js")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -45,9 +45,7 @@ import net.runelite.client.task.Schedule;
|
|||||||
import net.runelite.client.ui.ClientToolbar;
|
import net.runelite.client.ui.ClientToolbar;
|
||||||
import net.runelite.client.ui.NavigationButton;
|
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.FeedResult;
|
import net.runelite.http.api.feed.FeedResult;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "News Feed",
|
name = "News Feed",
|
||||||
@@ -145,10 +143,4 @@ public class FeedPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return configManager.getConfig(FeedConfig.class);
|
return configManager.getConfig(FeedConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
FeedClient provideFeedClient(OkHttpClient okHttpClient)
|
|
||||||
{
|
|
||||||
return new FeedClient(okHttpClient);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,18 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.ge;
|
package net.runelite.client.plugins.grandexchange;
|
||||||
|
|
||||||
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 javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
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;
|
||||||
import static net.runelite.http.api.RuneLiteAPI.JSON;
|
import static net.runelite.http.api.RuneLiteAPI.JSON;
|
||||||
|
import net.runelite.http.api.ge.GrandExchangeTrade;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
@@ -41,21 +43,28 @@ 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;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
@Setter
|
@Setter
|
||||||
private String machineId;
|
private String machineId;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GrandExchangeClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
}
|
||||||
|
|
||||||
public void submit(GrandExchangeTrade grandExchangeTrade)
|
public void submit(GrandExchangeTrade grandExchangeTrade)
|
||||||
{
|
{
|
||||||
final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
final HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("ge")
|
.addPathSegment("ge")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -100,11 +100,9 @@ import net.runelite.client.util.LinkBrowser;
|
|||||||
import net.runelite.client.util.OSType;
|
import net.runelite.client.util.OSType;
|
||||||
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.ge.GrandExchangeClient;
|
|
||||||
import net.runelite.http.api.ge.GrandExchangeTrade;
|
import net.runelite.http.api.ge.GrandExchangeTrade;
|
||||||
import net.runelite.http.api.item.ItemStats;
|
import net.runelite.http.api.item.ItemStats;
|
||||||
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;
|
||||||
|
|
||||||
@@ -259,12 +257,6 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
return configManager.getConfig(GrandExchangeConfig.class);
|
return configManager.getConfig(GrandExchangeConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
GrandExchangeClient provideGrandExchangeClient(OkHttpClient okHttpClient)
|
|
||||||
{
|
|
||||||
return new GrandExchangeClient(okHttpClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.loottracker;
|
package net.runelite.client.plugins.loottracker;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
@@ -35,12 +35,15 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
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;
|
||||||
import static net.runelite.http.api.RuneLiteAPI.JSON;
|
import static net.runelite.http.api.RuneLiteAPI.JSON;
|
||||||
|
import net.runelite.http.api.loottracker.LootAggregate;
|
||||||
|
import net.runelite.http.api.loottracker.LootRecord;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
@@ -50,21 +53,29 @@ import okhttp3.RequestBody;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class LootTrackerClient
|
public class LootTrackerClient
|
||||||
{
|
{
|
||||||
private static final Gson GSON = RuneLiteAPI.GSON;
|
private static final Gson GSON = RuneLiteAPI.GSON;
|
||||||
|
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private LootTrackerClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
|
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
|
||||||
{
|
{
|
||||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
|
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("loottracker")
|
.addPathSegment("loottracker")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -107,7 +118,7 @@ public class LootTrackerClient
|
|||||||
|
|
||||||
public Collection<LootAggregate> get() throws IOException
|
public Collection<LootAggregate> get() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("loottracker")
|
.addPathSegment("loottracker")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -137,7 +148,7 @@ public class LootTrackerClient
|
|||||||
|
|
||||||
public void delete(String eventId)
|
public void delete(String eventId)
|
||||||
{
|
{
|
||||||
HttpUrl.Builder builder = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl.Builder builder = apiBase.newBuilder()
|
||||||
.addPathSegment("loottracker");
|
.addPathSegment("loottracker");
|
||||||
|
|
||||||
if (eventId != null)
|
if (eventId != null)
|
||||||
@@ -65,7 +65,6 @@ import net.runelite.client.util.ImageUtil;
|
|||||||
import net.runelite.client.util.QuantityFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.client.util.SwingUtil;
|
import net.runelite.client.util.SwingUtil;
|
||||||
import net.runelite.http.api.loottracker.LootRecordType;
|
import net.runelite.http.api.loottracker.LootRecordType;
|
||||||
import net.runelite.http.api.loottracker.LootTrackerClient;
|
|
||||||
|
|
||||||
class LootTrackerPanel extends PluginPanel
|
class LootTrackerPanel extends PluginPanel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,8 +114,6 @@ import net.runelite.http.api.loottracker.GameItem;
|
|||||||
import net.runelite.http.api.loottracker.LootAggregate;
|
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 okhttp3.OkHttpClient;
|
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.text.WordUtils;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
@@ -340,12 +338,6 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
LootTrackerClient provideLootTrackerClient(OkHttpClient okHttpClient)
|
|
||||||
{
|
|
||||||
return new LootTrackerClient(okHttpClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
LootTrackerConfig provideConfig(ConfigManager configManager)
|
LootTrackerConfig provideConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ import net.runelite.api.events.GameStateChanged;
|
|||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageBuilder;
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
@@ -96,7 +97,6 @@ import static net.runelite.client.util.Text.sanitize;
|
|||||||
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.chat.ChatClient;
|
|
||||||
import net.runelite.http.api.chat.LayoutRoom;
|
import net.runelite.http.api.chat.LayoutRoom;
|
||||||
import net.runelite.http.api.ws.messages.party.PartyChatMessage;
|
import net.runelite.http.api.ws.messages.party.PartyChatMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ import net.runelite.api.widgets.Widget;
|
|||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageBuilder;
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
@@ -91,7 +92,6 @@ 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.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.chat.ChatClient;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
|
|||||||
@@ -22,11 +22,12 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.xp;
|
package net.runelite.client.plugins.xptracker;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
@@ -38,15 +39,18 @@ import okhttp3.Response;
|
|||||||
public class XpClient
|
public class XpClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
public XpClient(OkHttpClient client)
|
@Inject
|
||||||
|
private XpClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
{
|
{
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(String username)
|
public void update(String username)
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("xp")
|
.addPathSegment("xp")
|
||||||
.addPathSegment("update")
|
.addPathSegment("update")
|
||||||
.addQueryParameter("username", username)
|
.addQueryParameter("username", username)
|
||||||
@@ -69,8 +69,6 @@ import net.runelite.client.ui.NavigationButton;
|
|||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
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 okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "XP Tracker",
|
name = "XP Tracker",
|
||||||
@@ -139,12 +137,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.xtea;
|
package net.runelite.client.plugins.xtea;
|
||||||
|
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@@ -31,10 +31,13 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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 net.runelite.http.api.xtea.XteaKey;
|
||||||
|
import net.runelite.http.api.xtea.XteaRequest;
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
@@ -44,23 +47,28 @@ import okhttp3.RequestBody;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
|
||||||
public class XteaClient
|
public class XteaClient
|
||||||
{
|
{
|
||||||
private final OkHttpClient client;
|
private final OkHttpClient client;
|
||||||
|
private final HttpUrl apiBase;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private XteaClient(OkHttpClient client, @Named("runelite.api.base") HttpUrl apiBase)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
this.apiBase = apiBase;
|
||||||
|
}
|
||||||
|
|
||||||
public void submit(XteaRequest xteaRequest)
|
public void submit(XteaRequest xteaRequest)
|
||||||
{
|
{
|
||||||
String json = RuneLiteAPI.GSON.toJson(xteaRequest);
|
HttpUrl url = apiBase.newBuilder()
|
||||||
|
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
|
||||||
.addPathSegment("xtea")
|
.addPathSegment("xtea")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
log.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, RuneLiteAPI.GSON.toJson(xteaRequest)))
|
||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -75,7 +83,7 @@ public class XteaClient
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Call call, Response response)
|
public void onResponse(Call call, Response response)
|
||||||
{
|
{
|
||||||
try
|
try // NOPMD: UseTryWithResources
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -92,7 +100,7 @@ public class XteaClient
|
|||||||
|
|
||||||
public List<XteaKey> get() throws IOException
|
public List<XteaKey> get() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("xtea")
|
.addPathSegment("xtea")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -115,7 +123,7 @@ public class XteaClient
|
|||||||
|
|
||||||
public XteaKey get(int region) throws IOException
|
public XteaKey get(int region) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
HttpUrl url = apiBase.newBuilder()
|
||||||
.addPathSegment("xtea")
|
.addPathSegment("xtea")
|
||||||
.addPathSegment(Integer.toString(region))
|
.addPathSegment(Integer.toString(region))
|
||||||
.build();
|
.build();
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
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;
|
||||||
@@ -35,10 +34,8 @@ import net.runelite.api.events.GameStateChanged;
|
|||||||
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.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",
|
||||||
@@ -55,12 +52,6 @@ public class XteaPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private XteaClient xteaClient;
|
private XteaClient xteaClient;
|
||||||
|
|
||||||
@Provides
|
|
||||||
XteaClient provideXteaClient(OkHttpClient okHttpClient)
|
|
||||||
{
|
|
||||||
return new XteaClient(okHttpClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,9 +35,11 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.runelite.client.RuneLiteProperties;
|
||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldClient;
|
import net.runelite.client.game.WorldClient;
|
||||||
import net.runelite.http.api.worlds.WorldType;
|
import net.runelite.http.api.worlds.WorldType;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -46,7 +48,7 @@ class WorldSupplier implements Supplier<World>
|
|||||||
{
|
{
|
||||||
private final OkHttpClient okHttpClient;
|
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 final Queue<World> worlds = new ArrayDeque<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World get()
|
public World get()
|
||||||
@@ -58,7 +60,7 @@ class WorldSupplier implements Supplier<World>
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<World> newWorlds = new WorldClient(okHttpClient)
|
List<World> newWorlds = new WorldClient(okHttpClient, HttpUrl.get(RuneLiteProperties.getApiBase()))
|
||||||
.lookupWorlds()
|
.lookupWorlds()
|
||||||
.getWorlds()
|
.getWorlds()
|
||||||
.stream()
|
.stream()
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -40,6 +41,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.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -52,6 +54,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
{
|
{
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final OkHttpClient okHttpClient;
|
private final OkHttpClient okHttpClient;
|
||||||
|
private final HttpUrl runeliteWs;
|
||||||
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;
|
||||||
@@ -60,10 +63,11 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
private WebSocket webSocket;
|
private WebSocket webSocket;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WSClient(EventBus eventBus, OkHttpClient okHttpClient)
|
private WSClient(EventBus eventBus, OkHttpClient okHttpClient, @Named("runelite.ws") HttpUrl runeliteWs)
|
||||||
{
|
{
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.okHttpClient = okHttpClient;
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.runeliteWs = runeliteWs;
|
||||||
this.gson = WebsocketGsonFactory.build(WebsocketGsonFactory.factory(messages));
|
this.gson = WebsocketGsonFactory.build(WebsocketGsonFactory.factory(messages));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +105,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
}
|
}
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(RuneLiteAPI.getWsEndpoint())
|
.url(runeliteWs)
|
||||||
.header("User-Agent", RuneLiteAPI.userAgent)
|
.header("User-Agent", RuneLiteAPI.userAgent)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
@@ -13,3 +13,7 @@ runelite.jav_config_backup=https://static.runelite.net/jav_config.ws
|
|||||||
runelite.pluginhub.url=https://repo.runelite.net/plugins
|
runelite.pluginhub.url=https://repo.runelite.net/plugins
|
||||||
runelite.pluginhub.version=${project.version}
|
runelite.pluginhub.version=${project.version}
|
||||||
runelite.imgur.client.id=30d71e5f6860809
|
runelite.imgur.client.id=30d71e5f6860809
|
||||||
|
runelite.api.base=https://api.runelite.net/runelite-${project.version}
|
||||||
|
runelite.session=https://api.runelite.net/session
|
||||||
|
runelite.static.base=https://static.runelite.net
|
||||||
|
runelite.ws=https://api.runelite.net/ws
|
||||||
@@ -73,6 +73,10 @@ public class ConfigManagerTest
|
|||||||
@Bind
|
@Bind
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ConfigClient configClient;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ConfigManager manager;
|
ConfigManager manager;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
package net.runelite.client.hiscore;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.mockwebserver.MockResponse;
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -132,7 +132,7 @@ public class HiscoreClientTest
|
|||||||
@Test
|
@Test
|
||||||
public void testNormalLookup() throws Exception
|
public void testNormalLookup() throws Exception
|
||||||
{
|
{
|
||||||
HiscoreClient hiscoreClient = new HiscoreClient(RuneLiteAPI.CLIENT);
|
HiscoreClient hiscoreClient = new HiscoreClient(new OkHttpClient());
|
||||||
|
|
||||||
HiscoreResult result = hiscoreClient.lookup("zezima", server.url("/"));
|
HiscoreResult result = hiscoreClient.lookup("zezima", server.url("/"));
|
||||||
|
|
||||||
|
|||||||
@@ -49,17 +49,18 @@ import net.runelite.api.widgets.Widget;
|
|||||||
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
|
||||||
import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID;
|
import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
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.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.hiscore.HiscoreClient;
|
import net.runelite.client.hiscore.HiscoreClient;
|
||||||
import net.runelite.client.hiscore.HiscoreEndpoint;
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
import net.runelite.client.hiscore.HiscoreResult;
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
import net.runelite.client.hiscore.Skill;
|
import net.runelite.client.hiscore.Skill;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import net.runelite.http.api.chat.ChatClient;
|
|
||||||
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;
|
||||||
@@ -116,6 +117,10 @@ public class ChatCommandsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
RuneLiteConfig runeLiteConfig;
|
RuneLiteConfig runeLiteConfig;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
ItemManager itemManager;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
ChatCommandsConfig chatCommandsConfig;
|
ChatCommandsConfig chatCommandsConfig;
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import net.runelite.client.input.KeyManager;
|
|||||||
import net.runelite.client.input.MouseManager;
|
import net.runelite.client.input.MouseManager;
|
||||||
import static net.runelite.client.plugins.grandexchange.GrandExchangePlugin.findFuzzyIndices;
|
import static net.runelite.client.plugins.grandexchange.GrandExchangePlugin.findFuzzyIndices;
|
||||||
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.GrandExchangeTrade;
|
import net.runelite.http.api.ge.GrandExchangeTrade;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ import net.runelite.client.game.SpriteManager;
|
|||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.http.api.item.ItemPrice;
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
import net.runelite.http.api.loottracker.LootRecordType;
|
import net.runelite.http.api.loottracker.LootRecordType;
|
||||||
import net.runelite.http.api.loottracker.LootTrackerClient;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|||||||
@@ -31,13 +31,14 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
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.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 net.runelite.client.ws.WSClient;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -79,25 +80,33 @@ public class RaidsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
ChatClient chatClient;
|
ChatClient chatClient;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
InfoBoxManager infoBoxManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
PartyService partyService;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
OverlayManager overlayManager;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
WSClient wsClient;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
RaidsConfig raidsConfig;
|
RaidsConfig raidsConfig;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
RaidsOverlay raidsOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RaidsPlugin raidsPlugin;
|
RaidsPlugin raidsPlugin;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
private InfoBoxManager infoBoxManager;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
private PartyService partyService;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
private OverlayManager overlayManager;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before()
|
public void before()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import net.runelite.api.events.StatChanged;
|
|||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
@@ -59,7 +60,6 @@ import net.runelite.client.game.ItemManager;
|
|||||||
import net.runelite.client.game.npcoverlay.NpcOverlayService;
|
import net.runelite.client.game.npcoverlay.NpcOverlayService;
|
||||||
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.http.api.chat.ChatClient;
|
|
||||||
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;
|
||||||
@@ -142,6 +142,10 @@ public class SlayerPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
SlayerOverlay overlay;
|
SlayerOverlay overlay;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
TargetWeaknessOverlay targetWeaknessOverlay;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
InfoBoxManager infoBoxManager;
|
InfoBoxManager infoBoxManager;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import net.runelite.client.Notifier;
|
|||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.ws.PartyService;
|
import net.runelite.client.ws.PartyService;
|
||||||
|
import net.runelite.client.ws.WSClient;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -81,6 +82,10 @@ public class SpecialCounterPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
private Notifier notifier;
|
private Notifier notifier;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
@Bind
|
||||||
|
private WSClient wsClient;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
private SpecialCounterConfig specialCounterConfig;
|
private SpecialCounterConfig specialCounterConfig;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user