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