This commit is contained in:
Ian W. ONeill
2019-07-19 16:46:46 +01:00
44 changed files with 857 additions and 520 deletions

View File

@@ -26,6 +26,7 @@ package net.runelite.http.api.item;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import io.reactivex.Observable;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -112,7 +113,7 @@ public class ItemClient
} }
} }
public BufferedImage getIcon(int itemId) throws IOException public Observable<BufferedImage> getIcon(int itemId)
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("item") .addPathSegment("item")
@@ -126,23 +127,26 @@ public class ItemClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) return Observable.defer(() ->
{ {
if (!response.isSuccessful()) try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
logger.debug("Error grabbing icon {}: {}", itemId, response); if (!response.isSuccessful())
return null; {
} logger.debug("Error grabbing icon {}: {}", itemId, response);
return Observable.just(null);
}
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
synchronized (ImageIO.class) synchronized (ImageIO.class)
{ {
return ImageIO.read(in); return Observable.just(ImageIO.read(in));
}
} }
} });
} }
public SearchResult search(String itemName) throws IOException public Observable<SearchResult> search(String itemName)
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("item") .addPathSegment("item")
@@ -152,28 +156,31 @@ public class ItemClient
logger.debug("Built URI: {}", url); logger.debug("Built URI: {}", url);
Request request = new Request.Builder() return Observable.defer(() ->
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
if (!response.isSuccessful()) Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
logger.debug("Error looking up item {}: {}", itemName, response); if (!response.isSuccessful())
return null; {
} logger.debug("Error looking up item {}: {}", itemName, response);
return Observable.just(null);
}
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), SearchResult.class); return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), SearchResult.class));
} }
catch (JsonParseException ex) catch (JsonParseException ex)
{ {
throw new IOException(ex); return Observable.error(ex);
} }
});
} }
public ItemPrice[] getPrices() throws IOException public Observable<ItemPrice[]> getPrices()
{ {
HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder() HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("item") .addPathSegment("item")
@@ -183,28 +190,32 @@ public class ItemClient
logger.debug("Built URI: {}", url); logger.debug("Built URI: {}", url);
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) return Observable.defer(() ->
{ {
if (!response.isSuccessful()) Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
logger.warn("Error looking up prices: {}", response); if (!response.isSuccessful())
return null; {
} logger.warn("Error looking up prices: {}", response);
return Observable.just(null);
}
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), ItemPrice[].class); return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), ItemPrice[].class));
} }
catch (JsonParseException ex) catch (JsonParseException ex)
{ {
throw new IOException(ex); return Observable.error(ex);
} }
});
} }
public Map<Integer, ItemStats> getStats() throws IOException public Observable<Map<Integer, ItemStats>> getStats()
{ {
HttpUrl.Builder urlBuilder = RuneLiteAPI.getStaticBase().newBuilder() HttpUrl.Builder urlBuilder = RuneLiteAPI.getStaticBase().newBuilder()
.addPathSegment("item") .addPathSegment("item")
@@ -215,27 +226,31 @@ public class ItemClient
logger.debug("Built URI: {}", url); logger.debug("Built URI: {}", url);
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) return Observable.defer(() ->
{ {
if (!response.isSuccessful()) Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
logger.warn("Error looking up item stats: {}", response); if (!response.isSuccessful())
return null; {
logger.warn("Error looking up item stats: {}", response);
return Observable.just(null);
}
InputStream in = response.body().byteStream();
final Type typeToken = new TypeToken<Map<Integer, ItemStats>>()
{
}.getType();
return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), typeToken));
} }
catch (JsonParseException ex)
InputStream in = response.body().byteStream();
final Type typeToken = new TypeToken<Map<Integer, ItemStats>>()
{ {
}.getType(); return Observable.error(ex);
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), typeToken); }
} });
catch (JsonParseException ex)
{
throw new IOException(ex);
}
} }
} }

View File

@@ -58,7 +58,7 @@ public class OSBGrandExchangeClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
throw 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();

View File

@@ -26,6 +26,9 @@
package net.runelite.http.api.worlds; package net.runelite.http.api.worlds;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import io.reactivex.Observable;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.Request; import okhttp3.Request;
@@ -33,15 +36,11 @@ import okhttp3.Response;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class WorldClient public class WorldClient
{ {
private static final Logger logger = LoggerFactory.getLogger(WorldClient.class); private static final Logger logger = LoggerFactory.getLogger(WorldClient.class);
public WorldResult lookupWorlds() throws IOException public Observable<WorldResult> lookupWorlds()
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("worlds.js") .addPathSegment("worlds.js")
@@ -49,24 +48,27 @@ public class WorldClient
logger.debug("Built URI: {}", url); logger.debug("Built URI: {}", url);
Request request = new Request.Builder() return Observable.defer(() ->
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
if (!response.isSuccessful()) Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{ {
logger.debug("Error looking up worlds: {}", response); if (!response.isSuccessful())
return null; {
} logger.debug("Error looking up worlds: {}", response);
return Observable.just(null);
}
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), WorldResult.class); return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), WorldResult.class));
} }
catch (JsonParseException ex) catch (JsonParseException ex)
{ {
throw new IOException(ex); return Observable.error(ex);
} }
});
} }
} }

View File

@@ -1,12 +1,12 @@
{ {
"buildCommit": "b82c8903c64695d44b255d45b449440e4eaa17ef", "buildCommit": "6fe334c02648d3f8b38625e3175e3f547d54aa37",
"client": { "client": {
"artifactId": "client", "artifactId": "client",
"classifier": "", "classifier": "",
"extension": "jar", "extension": "jar",
"groupId": "net.runelite", "groupId": "net.runelite",
"properties": "", "properties": "",
"version": "1.5.29" "version": "1.5.30"
}, },
"clientJvm9Arguments": [ "clientJvm9Arguments": [
"-XX:+DisableAttachMechanism", "-XX:+DisableAttachMechanism",
@@ -56,10 +56,10 @@
"size": "3168921" "size": "3168921"
}, },
{ {
"hash": "08774848b10e8f76f96f364150a956d13c798e7c266d88cd0a0534e1f2f26c30", "hash": "d982191ebbd930b573e6d2242cdfefefdf1c610f1f046e204866749eefde1c5f",
"name": "client-1.5.29-SNAPSHOT.jar", "name": "client-1.5.30-SNAPSHOT.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/client-1.5.29-SNAPSHOT.jar", "path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/client-1.5.30-SNAPSHOT.jar",
"size": "6185577" "size": "6280727"
}, },
{ {
"hash": "18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79", "hash": "18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79",
@@ -248,22 +248,22 @@
"size": "2327547" "size": "2327547"
}, },
{ {
"hash": "b98cb800d9013cb3d84ba89a8ea8d54b88d66a2010f282cbf0265953b3f37491", "hash": "c0a81abdd6a7486851ef7f0df2ce70d7e362fb033eb5c4267a4a476e35a1824a",
"name": "runelite-api-1.5.29-SNAPSHOT.jar", "name": "runelite-api-1.5.30-SNAPSHOT.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/runelite-api-1.5.29-SNAPSHOT.jar", "path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/runelite-api-1.5.30-SNAPSHOT.jar",
"size": "1031527" "size": "1033784"
}, },
{ {
"hash": "bfbd1bdea706a23799f9630adad9825acc358b8185a1cb8356853032f99d1a22", "hash": "e8e743c2eb9e59f2990a5bdc48f061b7138890f065c0d603ecb8cdf0b0b158f7",
"name": "runescape-api-1.5.29-SNAPSHOT.jar", "name": "runescape-api-1.5.30-SNAPSHOT.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/runescape-api-1.5.29-SNAPSHOT.jar", "path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/runescape-api-1.5.30-SNAPSHOT.jar",
"size": "58397" "size": "58398"
}, },
{ {
"hash": "7ad65d4043416ddb09769c0b554fd43a9aa906d6934de03639310c6c552ecc6e", "hash": "fea59d29ac883248bcc77a5f05b0cefebc226583d291f52d377e39db06fe7d19",
"name": "http-api-1.5.29-SNAPSHOT.jar", "name": "http-api-1.5.30-SNAPSHOT.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/http-api-1.5.29-SNAPSHOT.jar", "path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/http-api-1.5.30-SNAPSHOT.jar",
"size": "138036" "size": "139678"
}, },
{ {
"hash": "f55abda036da75e1af45bd43b9dfa79b2a3d90905be9cb38687c6621597a8165", "hash": "f55abda036da75e1af45bd43b9dfa79b2a3d90905be9cb38687c6621597a8165",
@@ -290,10 +290,28 @@
"size": "617294" "size": "617294"
}, },
{ {
"hash": "01521c7b56e2f76aa7adef5082c2f8ee8cf9e93b02d3b2f4101a30f750db9db4", "hash": "9f5333cb045ebd90b1ee457f1ceafc1a085265232926a24fb582ff1960bef703",
"name": "injected-client-1.5.29-SNAPSHOT.jar", "name": "injected-client-1.5.30-SNAPSHOT.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/injected-client-1.5.29-SNAPSHOT.jar", "path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/injected-client-1.5.30-SNAPSHOT.jar",
"size": "2252769" "size": "2253443"
},
{
"hash": "21b5cac673a156cd8d6cf9efe15ff267b6353eeb129678aa4b39542683ba0dc2",
"name": "rxjava-2.2.10.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/rxjava-2.2.10.jar",
"size": "2348810"
},
{
"hash": "830a08b9d5c20ab8e2033c16fc6ee067e6ffcd0c730f303d648aadfa81210d62",
"name": "rxrelay-2.1.0.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/rxrelay-2.1.0.jar",
"size": "27750"
},
{
"hash": "830a08b9d5c20ab8e2033c16fc6ee067e6ffcd0c730f303d648aadfa81210d62",
"name": "reactive-streams-1.0.2.jar",
"path": "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/reactive-streams-1.0.2.jar",
"size": "27750"
} }
] ]
} }

View File

@@ -49,6 +49,11 @@ public enum Varbits
*/ */
CHAT_SCROLLBAR_ON_LEFT(6374), CHAT_SCROLLBAR_ON_LEFT(6374),
/**
* Grand Exchange
*/
GRAND_EXCHANGE_PRICE_PER_ITEM(4398),
/** /**
* Runepouch * Runepouch
*/ */

View File

@@ -48,9 +48,15 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.account.SessionManager; import net.runelite.client.account.SessionManager;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.CommandManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.discord.DiscordService; import net.runelite.client.discord.DiscordService;
import net.runelite.client.game.ClanManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.LootManager;
import net.runelite.client.game.chatbox.ChatboxPanelManager;
import net.runelite.client.graphics.ModelOutlineRenderer; import net.runelite.client.graphics.ModelOutlineRenderer;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginInstantiationException; import net.runelite.client.plugins.PluginInstantiationException;
import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginManager;
@@ -58,21 +64,25 @@ import net.runelite.client.rs.ClientLoader;
import net.runelite.client.rs.ClientUpdateCheckMode; import net.runelite.client.rs.ClientUpdateCheckMode;
import net.runelite.client.task.Scheduler; import net.runelite.client.task.Scheduler;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.RuneLiteSplashScreen; import net.runelite.client.ui.RuneLiteSplashScreen;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.OverlayRenderer;
import net.runelite.client.ui.overlay.WidgetOverlay; import net.runelite.client.ui.overlay.WidgetOverlay;
import net.runelite.client.ui.overlay.arrow.ArrowMinimapOverlay; import net.runelite.client.ui.overlay.arrow.ArrowMinimapOverlay;
import net.runelite.client.ui.overlay.arrow.ArrowWorldOverlay; import net.runelite.client.ui.overlay.arrow.ArrowWorldOverlay;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay; import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay;
import net.runelite.client.ui.overlay.tooltip.TooltipOverlay; import net.runelite.client.ui.overlay.tooltip.TooltipOverlay;
import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay; import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
import net.runelite.client.ws.PartyService;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Singleton @Singleton
@Slf4j @Slf4j
public class RuneLite public class RuneLite
{ {
public static final String RUNELIT_VERSION = "2.0.3"; public static final String RUNELIT_VERSION = "2.0.4";
public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite"); public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles"); public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles");
public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins"); public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
@@ -89,6 +99,9 @@ public class RuneLite
@Inject @Inject
private ConfigManager configManager; private ConfigManager configManager;
@Inject
private DrawManager drawManager;
@Inject @Inject
private SessionManager sessionManager; private SessionManager sessionManager;
@@ -101,12 +114,33 @@ public class RuneLite
@Inject @Inject
private ClientUI clientUI; private ClientUI clientUI;
@Inject
private InfoBoxManager infoBoxManager;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject
private PartyService partyService;
@Inject
private Provider<ItemManager> itemManager;
@Inject
private Provider<OverlayRenderer> overlayRenderer;
@Inject
private Provider<ClanManager> clanManager;
@Inject @Inject
private Provider<ChatMessageManager> chatMessageManager; private Provider<ChatMessageManager> chatMessageManager;
@Inject
private Provider<MenuManager> menuManager;
@Inject
private Provider<CommandManager> commandManager;
@Inject @Inject
private Provider<InfoBoxOverlay> infoBoxOverlay; private Provider<InfoBoxOverlay> infoBoxOverlay;
@@ -122,6 +156,12 @@ public class RuneLite
@Inject @Inject
private Provider<ArrowMinimapOverlay> arrowMinimapOverlay; private Provider<ArrowMinimapOverlay> arrowMinimapOverlay;
@Inject
private Provider<LootManager> lootManager;
@Inject
private Provider<ChatboxPanelManager> chatboxPanelManager;
@Inject @Inject
@Nullable @Nullable
private Client client; private Client client;
@@ -166,7 +206,7 @@ public class RuneLite
if (options.has("proxy")) if (options.has("proxy"))
{ {
String[] proxy = options.valueOf(proxyInfo).split(":"); String[] proxy = options.valueOf(proxyInfo).split(":");
if (proxy.length >= 2) if (proxy.length >= 2)
{ {
System.setProperty("socksProxyHost", proxy[0]); System.setProperty("socksProxyHost", proxy[0]);
@@ -312,6 +352,15 @@ public class RuneLite
// Initialize chat colors // Initialize chat colors
chatMessageManager.get().loadColors(); chatMessageManager.get().loadColors();
overlayRenderer.get();
clanManager.get();
itemManager.get();
menuManager.get();
chatMessageManager.get();
commandManager.get();
lootManager.get();
chatboxPanelManager.get();
// Add core overlays // Add core overlays
WidgetOverlay.createOverlays(client).forEach(overlayManager::add); WidgetOverlay.createOverlays(client).forEach(overlayManager::add);
overlayManager.add(infoBoxOverlay.get()); overlayManager.add(infoBoxOverlay.get());

View File

@@ -27,14 +27,16 @@ package net.runelite.client.callback;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.function.BooleanSupplier; import java.util.function.BooleanSupplier;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import org.jetbrains.annotations.NotNull;
@Singleton @Singleton
@Slf4j @Slf4j
public class ClientThread public class ClientThread implements Executor
{ {
private final ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>(); private final ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
@@ -112,4 +114,14 @@ public class ClientThread
} }
} }
} }
@Override
public void execute(@NotNull Runnable r)
{
invoke(() ->
{
r.run();
return true;
});
}
} }

View File

@@ -30,9 +30,9 @@ import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import io.reactivex.schedulers.Schedulers;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@@ -142,6 +142,7 @@ public class ItemManager
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines; private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap(); private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private Map<Integer, ItemStats> itemStats = Collections.emptyMap(); private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
@Inject @Inject
public ItemManager( public ItemManager(
Client client, Client client,
@@ -209,43 +210,43 @@ public class ItemManager
private void loadPrices() private void loadPrices()
{ {
try itemClient.getPrices()
{ .subscribeOn(Schedulers.io())
ItemPrice[] prices = itemClient.getPrices(); .subscribe(
if (prices != null) (prices) ->
{
ImmutableMap.Builder<Integer, ItemPrice> map = ImmutableMap.builderWithExpectedSize(prices.length);
for (ItemPrice price : prices)
{ {
map.put(price.getId(), price); if (prices != null)
} {
itemPrices = map.build(); ImmutableMap.Builder<Integer, ItemPrice> map = ImmutableMap.builderWithExpectedSize(prices.length);
} for (ItemPrice price : prices)
{
map.put(price.getId(), price);
}
itemPrices = map.build();
}
log.debug("Loaded {} prices", itemPrices.size()); log.debug("Loaded {} prices", itemPrices.size());
} },
catch (IOException e) (e) -> log.warn("error loading prices!", e)
{ );
log.warn("error loading prices!", e);
}
} }
private void loadStats() private void loadStats()
{ {
try itemClient.getStats()
{ .subscribeOn(Schedulers.io())
final Map<Integer, ItemStats> stats = itemClient.getStats(); .subscribe(
if (stats != null) (stats) ->
{ {
itemStats = ImmutableMap.copyOf(stats); if (stats != null)
} {
itemStats = ImmutableMap.copyOf(stats);
}
log.debug("Loaded {} stats", itemStats.size()); log.debug("Loaded {} stats", itemStats.size());
} },
catch (IOException e) (e) -> log.warn("error loading stats!", e)
{ );
log.warn("error loading stats!", e);
}
} }
private void onGameStateChanged(final GameStateChanged event) private void onGameStateChanged(final GameStateChanged event)
@@ -285,7 +286,7 @@ public class ItemManager
/** /**
* Look up an item's price * Look up an item's price
* *
* @param itemID item id * @param itemID item id
* @param ignoreUntradeableMap should the price returned ignore the {@link UntradeableItemMapping} * @param ignoreUntradeableMap should the price returned ignore the {@link UntradeableItemMapping}
* @return item price * @return item price
*/ */

View File

@@ -34,12 +34,14 @@ import java.awt.Polygon;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.Set; import java.util.Iterator;
import java.util.Map;
import javax.inject.Inject; 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.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.Projectile;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
@@ -90,35 +92,32 @@ public class AoeWarningOverlay extends Overlay
} }
Instant now = Instant.now(); Instant now = Instant.now();
Set<ProjectileContainer> projectiles = plugin.getProjectiles(); Map<Projectile, AoeProjectile> projectiles = plugin.getProjectiles();
projectiles.forEach(proj -> for (Iterator<AoeProjectile> it = projectiles.values().iterator(); it.hasNext(); )
{ {
if (proj.getTargetPoint() == null) AoeProjectile aoeProjectile = it.next();
{
return;
}
Color color; Color color;
if (now.isAfter(aoeProjectile.getStartTime().plus(Duration.ofMillis(aoeProjectile.getProjectileLifetime()))))
if (now.isAfter(proj.getStartTime().plus(Duration.ofMillis(proj.getLifetime()))))
{ {
return; it.remove();
continue;
} }
final Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, proj.getTargetPoint(), proj.getAoeProjectileInfo().getAoeSize()); Polygon tilePoly = Perspective.getCanvasTileAreaPoly(client, aoeProjectile.getTargetPoint(), aoeProjectile.getAoeProjectileInfo().getAoeSize());
if (tilePoly == null) if (tilePoly == null)
{ {
return; continue;
} }
final double progress = (System.currentTimeMillis() - proj.getStartTime().toEpochMilli()) / (double) proj.getLifetime(); // how far through the projectiles lifetime between 0-1.
double progress = (System.currentTimeMillis() - aoeProjectile.getStartTime().toEpochMilli()) / (double) aoeProjectile.getProjectileLifetime();
final int tickProgress = proj.getFinalTick() - client.getTickCount(); int tickProgress = aoeProjectile.getFinalTick() - client.getTickCount();
int fillAlpha, outlineAlpha; int fillAlpha, outlineAlpha;
if (plugin.isConfigFadeEnabled()) if (plugin.isConfigFadeEnabled())
{ {
fillAlpha = (int) ((1 - progress) * FILL_START_ALPHA); fillAlpha = (int) ((1 - progress) * FILL_START_ALPHA);//alpha drop off over lifetime
outlineAlpha = (int) ((1 - progress) * OUTLINE_START_ALPHA); outlineAlpha = (int) ((1 - progress) * OUTLINE_START_ALPHA);
} }
else else
@@ -166,8 +165,7 @@ public class AoeWarningOverlay extends Overlay
graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true)); graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true));
graphics.fillPolygon(tilePoly); graphics.fillPolygon(tilePoly);
}); }
projectiles.removeIf(proj -> now.isAfter(proj.getStartTime().plus(Duration.ofMillis(proj.getLifetime()))));
return null; return null;
} }

View File

@@ -32,10 +32,9 @@ import java.awt.Color;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
@@ -45,6 +44,7 @@ import net.runelite.api.Client;
import net.runelite.api.GameObject; import net.runelite.api.GameObject;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.GraphicID; import net.runelite.api.GraphicID;
import net.runelite.api.GraphicsObject;
import net.runelite.api.NullObjectID; import net.runelite.api.NullObjectID;
import net.runelite.api.ObjectID; import net.runelite.api.ObjectID;
import net.runelite.api.Projectile; import net.runelite.api.Projectile;
@@ -57,7 +57,6 @@ import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.events.ProjectileSpawned;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
@@ -80,7 +79,7 @@ public class AoeWarningPlugin extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final Map<WorldPoint, CrystalBomb> bombs = new HashMap<>(); private final Map<WorldPoint, CrystalBomb> bombs = new HashMap<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private final Set<ProjectileContainer> projectiles = new HashSet<>(); private final Map<Projectile, AoeProjectile> projectiles = new HashMap<>();
@Inject @Inject
public AoeWarningConfig config; public AoeWarningConfig config;
@Inject @Inject
@@ -103,6 +102,13 @@ public class AoeWarningPlugin extends Plugin
private List<WorldPoint> CrystalSpike = new ArrayList<>(); private List<WorldPoint> CrystalSpike = new ArrayList<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private List<WorldPoint> WintertodtSnowFall = new ArrayList<>(); private List<WorldPoint> WintertodtSnowFall = new ArrayList<>();
@Provides
AoeWarningConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(AoeWarningConfig.class);
}
// Config values // Config values
private boolean aoeNotifyAll; private boolean aoeNotifyAll;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -162,17 +168,12 @@ public class AoeWarningPlugin extends Plugin
private boolean configDemonicGorillaEnabled; private boolean configDemonicGorillaEnabled;
private boolean configDemonicGorillaNotifyEnabled; private boolean configDemonicGorillaNotifyEnabled;
@Provides
AoeWarningConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(AoeWarningConfig.class);
}
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions(); addSubscriptions();
overlayManager.add(coreOverlay); overlayManager.add(coreOverlay);
overlayManager.add(bombOverlay); overlayManager.add(bombOverlay);
reset(); reset();
@@ -196,7 +197,6 @@ public class AoeWarningPlugin extends Plugin
eventbus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned); eventbus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged); eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(GameTick.class, this, this::onGameTick); eventbus.subscribe(GameTick.class, this, this::onGameTick);
eventbus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned);
} }
private void onConfigChanged(ConfigChanged event) private void onConfigChanged(ConfigChanged event)
@@ -209,52 +209,33 @@ public class AoeWarningPlugin extends Plugin
updateConfig(); updateConfig();
} }
private void onProjectileSpawned(ProjectileSpawned event) private void onProjectileMoved(ProjectileMoved event)
{ {
final Projectile projectile = event.getProjectile(); Projectile projectile = event.getProjectile();
if (AoeProjectileInfo.getById(projectile.getId()) == null) int projectileId = projectile.getId();
{ int projectileLifetime = this.delay + (projectile.getRemainingCycles() * 20);
return;
}
final int id = projectile.getId();
final int lifetime = this.delay + (projectile.getRemainingCycles() * 20);
int ticksRemaining = projectile.getRemainingCycles() / 30; int ticksRemaining = projectile.getRemainingCycles() / 30;
if (!isTickTimersEnabledForProjectileID(id)) if (!isTickTimersEnabledForProjectileID(projectileId))
{ {
ticksRemaining = 0; ticksRemaining = 0;
} }
final int tickCycle = client.getTickCount() + ticksRemaining; int tickCycle = client.getTickCount() + ticksRemaining;
if (isConfigEnabledForProjectileId(id, false)) AoeProjectileInfo aoeProjectileInfo = AoeProjectileInfo.getById(projectileId);
if (aoeProjectileInfo != null
&& isConfigEnabledForProjectileId(projectileId, false))
{ {
projectiles.add(new ProjectileContainer(projectile, Instant.now(), lifetime, tickCycle)); LocalPoint targetPoint = event.getPosition();
AoeProjectile aoeProjectile = new AoeProjectile(Instant.now(), targetPoint, aoeProjectileInfo, projectileLifetime, tickCycle);
projectiles.put(projectile, aoeProjectile);
if (this.aoeNotifyAll || isConfigEnabledForProjectileId(id, true)) if (this.aoeNotifyAll || isConfigEnabledForProjectileId(projectileId, true))
{ {
notifier.notify("AoE attack detected!"); notifier.notify("AoE attack detected!");
} }
} }
} }
private void onProjectileMoved(ProjectileMoved event)
{
if (projectiles.isEmpty())
{
return;
}
final Projectile projectile = event.getProjectile();
projectiles.forEach(proj ->
{
if (proj.getProjectile() == projectile)
{
proj.setTargetPoint(event.getPosition());
}
});
}
private void onGameObjectSpawned(GameObjectSpawned event) private void onGameObjectSpawned(GameObjectSpawned event)
{ {
final GameObject gameObject = event.getGameObject(); final GameObject gameObject = event.getGameObject();
@@ -277,6 +258,7 @@ public class AoeWarningPlugin extends Plugin
CrystalSpike.add(wp); CrystalSpike.add(wp);
break; break;
case NullObjectID.NULL_26690: case NullObjectID.NULL_26690:
//Wintertodt Snowfall
if (this.configWintertodtEnabled) if (this.configWintertodtEnabled)
{ {
WintertodtSnowFall.add(wp); WintertodtSnowFall.add(wp);
@@ -306,7 +288,11 @@ public class AoeWarningPlugin extends Plugin
CrystalSpike.remove(wp); CrystalSpike.remove(wp);
break; break;
case NullObjectID.NULL_26690: case NullObjectID.NULL_26690:
WintertodtSnowFall.remove(wp); //Wintertodt Snowfall
if (this.configWintertodtEnabled)
{
WintertodtSnowFall.remove(wp);
}
break; break;
} }
} }
@@ -321,11 +307,10 @@ public class AoeWarningPlugin extends Plugin
private void onGameTick(GameTick event) private void onGameTick(GameTick event)
{ {
LightningTrail.clear();
if (this.configLightningTrail) if (this.configLightningTrail)
{ {
client.getGraphicsObjects().forEach(o -> LightningTrail.clear();
for (GraphicsObject o : client.getGraphicsObjects())
{ {
if (o.getId() == GraphicID.OLM_LIGHTNING) if (o.getId() == GraphicID.OLM_LIGHTNING)
{ {
@@ -336,29 +321,34 @@ public class AoeWarningPlugin extends Plugin
notifier.notify("Lightning!"); notifier.notify("Lightning!");
} }
} }
}); }
} }
bombs.forEach((k, v) -> for (Map.Entry<WorldPoint, CrystalBomb> entry : bombs.entrySet())
{ {
v.bombClockUpdate(); CrystalBomb bomb = entry.getValue();
}); bomb.bombClockUpdate();
//bombClockUpdate smooths the shown timer; not using this results in 1.2 --> .6 vs. 1.2 --> 1.1, etc.
}
} }
private void purgeBombs(Map<WorldPoint, CrystalBomb> bombs) private void purgeBombs(Map<WorldPoint, CrystalBomb> bombs)
{ {
Iterator<Map.Entry<WorldPoint, CrystalBomb>> it = bombs.entrySet().iterator();
Tile[][][] tiles = client.getScene().getTiles(); Tile[][][] tiles = client.getScene().getTiles();
bombs.forEach((k, v) -> while (it.hasNext())
{ {
LocalPoint local = LocalPoint.fromWorld(client, k); Map.Entry<WorldPoint, CrystalBomb> entry = it.next();
WorldPoint world = entry.getKey();
LocalPoint local = LocalPoint.fromWorld(client, world);
if (local == null) if (local == null)
{ {
return; return;
} }
Tile tile = tiles[k.getPlane()][local.getSceneX()][local.getSceneY()]; Tile tile = tiles[world.getPlane()][local.getSceneX()][local.getSceneY()];
GameObject[] objects = tile.getGameObjects(); GameObject[] objects = tile.getGameObjects();
boolean containsObjects = false; boolean containsObjects = false;
@@ -372,9 +362,10 @@ public class AoeWarningPlugin extends Plugin
if (!containsObjects) if (!containsObjects)
{ {
bombs.remove(k, v); it.remove();
} }
});
}
} }
private boolean isTickTimersEnabledForProjectileID(int projectileId) private boolean isTickTimersEnabledForProjectileID(int projectileId)

View File

@@ -33,11 +33,13 @@ import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.time.Instant; import java.time.Instant;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Player;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
@@ -53,13 +55,24 @@ public class BombOverlay extends Overlay
{ {
private static final String SAFE = "#00cc00"; private static final String SAFE = "#00cc00";
//safe
private static final String CAUTION = "#ffff00"; private static final String CAUTION = "#ffff00";
//1 tile in range (minor damage)
private static final String WARNING = "#ff9933"; private static final String WARNING = "#ff9933";
//2 tiles in range (moderate damage)
private static final String DANGER = "#ff6600"; private static final String DANGER = "#ff6600";
//3 tiles in range/adjacent to bomb (major damage)
private static final String LETHAL = "#cc0000"; private static final String LETHAL = "#cc0000";
//On the bomb, using it as a makeshift space launch vehicle. (massive damage)
private static final int BOMB_AOE = 7; private static final int BOMB_AOE = 7;
private static final int BOMB_DETONATE_TIME = 8; private static final int BOMB_DETONATE_TIME = 8;
//This is in ticks. It should be 10, but it varies from 8 to 11.
private static final double ESTIMATED_TICK_LENGTH = .6; private static final double ESTIMATED_TICK_LENGTH = .6;
//Thank you Woox & co. for this assumption. .6 seconds/tick.
//Utilized from the npc highlight code for formatting text being displayed on the client canvas.
private static final NumberFormat TIME_LEFT_FORMATTER = private static final NumberFormat TIME_LEFT_FORMATTER =
DecimalFormat.getInstance(Locale.US); DecimalFormat.getInstance(Locale.US);
@@ -86,72 +99,84 @@ public class BombOverlay extends Overlay
{ {
if (plugin.isConfigbombDisplay()) if (plugin.isConfigbombDisplay())
{ {
drawDangerZone(graphics); drawBombs(graphics);
} }
return null; return null;
} }
private void drawDangerZone(Graphics2D graphics) private void drawBombs(Graphics2D graphics)
//I can condense drawDangerZone into this. Ambivalent though.
{ {
final WorldPoint loc = client.getLocalPlayer().getWorldLocation(); for (Map.Entry<WorldPoint, CrystalBomb> entry : plugin.getBombs().entrySet())
plugin.getBombs().forEach((k, v) ->
{ {
LocalPoint localLoc = LocalPoint.fromWorld(client, v.getWorldLocation()); CrystalBomb bomb = entry.getValue();
drawDangerZone(graphics, bomb);
}
}
if (localLoc == null) private void drawDangerZone(Graphics2D graphics, CrystalBomb bomb)
{ {
return; final Player localPlayer = client.getLocalPlayer();
} LocalPoint localLoc = LocalPoint.fromWorld(client, bomb.getWorldLocation());
if (localLoc == null)
{
return;
}
double distance_x = Math.abs(bomb.getWorldLocation().getX() - localPlayer.getWorldLocation().getX());
double distance_y = Math.abs(bomb.getWorldLocation().getY() - localPlayer.getWorldLocation().getY());
Color color_code = Color.decode(SAFE);
//defaults to this unless conditionals met below.
final double distance_x = Math.abs(v.getWorldLocation().getX() - loc.getX()); if (distance_x < 1 && distance_y < 1)
final double distance_y = Math.abs(v.getWorldLocation().getY() - loc.getY()); {
color_code = Color.decode(LETHAL);
}
else if (distance_x < 2 && distance_y < 2)
{
color_code = Color.decode(DANGER);
}
else if (distance_x < 3 && distance_y < 3)
{
color_code = Color.decode(WARNING);
}
else if (distance_x < 4 && distance_y < 4)
{
color_code = Color.decode(CAUTION);
}
LocalPoint CenterPoint = new LocalPoint(localLoc.getX(), localLoc.getY());
Polygon poly = Perspective.getCanvasTileAreaPoly(client, CenterPoint, BOMB_AOE);
Color color_code = Color.decode(SAFE); if (poly != null)
{
//manually generating the polygon so as to assign a custom alpha value. Request adtl' arg for alpha maybe?
graphics.setColor(color_code);
graphics.setStroke(new BasicStroke(1));
graphics.drawPolygon(poly);
graphics.setColor(new Color(0, 0, 0, 10));
graphics.fillPolygon(poly);
}
if (distance_x < 1 && distance_y < 1) Instant now = Instant.now();
{ double timeLeft = ((BOMB_DETONATE_TIME - (client.getTickCount() -
color_code = Color.decode(LETHAL); bomb.getTickStarted())) * ESTIMATED_TICK_LENGTH) -
} (now.toEpochMilli() - bomb.getLastClockUpdate().toEpochMilli()) / 1000.0;
else if (distance_x < 2 && distance_y < 2) //divided by 1000.00 because of milliseconds :)
{
color_code = Color.decode(DANGER);
}
else if (distance_x < 3 && distance_y < 3)
{
color_code = Color.decode(WARNING);
}
else if (distance_x < 4 && distance_y < 4)
{
color_code = Color.decode(CAUTION);
}
final LocalPoint CenterPoint = new LocalPoint(localLoc.getX(), localLoc.getY());
final Polygon poly = Perspective.getCanvasTileAreaPoly(client, CenterPoint, BOMB_AOE);
if (poly != null) timeLeft = Math.max(0.0, timeLeft);
{ String bombTimerString = TIME_LEFT_FORMATTER.format(timeLeft);
graphics.setColor(color_code); int textWidth = graphics.getFontMetrics().stringWidth(bombTimerString);
graphics.setStroke(new BasicStroke(1)); int textHeight = graphics.getFontMetrics().getAscent();
graphics.drawPolygon(poly); Point canvasPoint = Perspective.localToCanvas(client, localLoc.getX(),
graphics.setColor(new Color(0, 0, 0, 10)); localLoc.getY(), bomb.getWorldLocation().getPlane());
graphics.fillPolygon(poly);
}
final Instant now = Instant.now(); if (canvasPoint != null)
double timeLeft = ((BOMB_DETONATE_TIME - (client.getTickCount() - v.getTickStarted())) * ESTIMATED_TICK_LENGTH) - {
(now.toEpochMilli() - v.getLastClockUpdate().toEpochMilli()) / 1000.0; Point canvasCenterPoint = new Point(
canvasPoint.getX() - textWidth / 2,
canvasPoint.getY() + textHeight / 2);
OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, bombTimerString, color_code);
}
timeLeft = Math.max(0.0, timeLeft);
final String bombTimerString = TIME_LEFT_FORMATTER.format(timeLeft);
final int textWidth = graphics.getFontMetrics().stringWidth(bombTimerString);
final int textHeight = graphics.getFontMetrics().getAscent();
final Point canvasPoint = Perspective.localToCanvas(client, localLoc.getX(), localLoc.getY(), v.getWorldLocation().getPlane());
if (canvasPoint != null)
{
Point canvasCenterPoint = new Point(canvasPoint.getX() - textWidth / 2, canvasPoint.getY() + textHeight / 2);
OverlayUtil.renderTextLocation(graphics, canvasCenterPoint, bombTimerString, color_code);
}
});
} }
} }

View File

@@ -32,13 +32,22 @@ import net.runelite.api.GameObject;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
@Slf4j @Slf4j
@Getter(AccessLevel.PACKAGE)
class CrystalBomb class CrystalBomb
{ {
@Getter(AccessLevel.PACKAGE)
private Instant plantedOn; private Instant plantedOn;
@Getter(AccessLevel.PACKAGE)
private Instant lastClockUpdate; private Instant lastClockUpdate;
@Getter(AccessLevel.PACKAGE)
private int objectId; private int objectId;
@Getter(AccessLevel.PACKAGE)
private int tickStarted; private int tickStarted;
//
@Getter(AccessLevel.PACKAGE)
private WorldPoint worldLocation; private WorldPoint worldLocation;
CrystalBomb(GameObject gameObject, int startTick) CrystalBomb(GameObject gameObject, int startTick)

View File

@@ -1,30 +0,0 @@
package net.runelite.client.plugins.aoewarnings;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Projectile;
import net.runelite.api.coords.LocalPoint;
@Getter(AccessLevel.PACKAGE)
class ProjectileContainer
{
private Projectile projectile;
private Instant startTime;
private AoeProjectileInfo aoeProjectileInfo;
private int lifetime;
private int finalTick;
@Setter(AccessLevel.PACKAGE)
private LocalPoint targetPoint;
ProjectileContainer(Projectile projectile, Instant startTime, int lifetime, int finalTick)
{
this.projectile = projectile;
this.startTime = startTime;
this.targetPoint = null;
this.aoeProjectileInfo = AoeProjectileInfo.getById(projectile.getId());
this.lifetime = lifetime;
this.finalTick = finalTick;
}
}

View File

@@ -129,4 +129,15 @@ public interface ChatCommandsConfig extends Config
{ {
return true; return true;
} }
@ConfigItem(
position = 5,
keyName = "clipboardShortcuts",
name = "Clipboard shortcuts",
description = "Enable clipboard shortcuts (ctrl+c and ctrl+v)"
)
default boolean clipboardShortcuts()
{
return true;
}
} }

View File

@@ -827,45 +827,45 @@ public class ChatCommandsPlugin extends Plugin
{ {
ItemPrice item = retrieveFromList(results, search); ItemPrice item = retrieveFromList(results, search);
CLIENT.lookupItem(item.getId()) CLIENT.lookupItem(item.getId())
.subscribeOn(Schedulers.single()) .subscribeOn(Schedulers.io())
.observeOn(Schedulers.from(clientThread))
.subscribe( .subscribe(
(osbresult) -> (osbresult) ->
clientThread.invoke(() -> {
int itemId = item.getId();
int itemPrice = itemManager.getItemPrice(itemId);
final ChatMessageBuilder builder = new ChatMessageBuilder();
builder.append(ChatColorType.NORMAL);
builder.append(ChatColorType.HIGHLIGHT);
builder.append(item.getName());
builder.append(ChatColorType.NORMAL);
builder.append(": GE ");
builder.append(ChatColorType.HIGHLIGHT);
builder.append(StackFormatter.formatNumber(itemPrice));
builder.append(ChatColorType.NORMAL);
builder.append(": OSB ");
builder.append(ChatColorType.HIGHLIGHT);
builder.append(StackFormatter.formatNumber(osbresult.getOverall_average()));
ItemDefinition itemComposition = itemManager.getItemDefinition(itemId);
if (itemComposition != null)
{ {
int itemId = item.getId(); int alchPrice = itemManager.getAlchValue(itemId);
int itemPrice = itemManager.getItemPrice(itemId); builder
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice));
}
final ChatMessageBuilder builder = new ChatMessageBuilder(); String response = builder.build();
builder.append(ChatColorType.NORMAL);
builder.append(ChatColorType.HIGHLIGHT);
builder.append(item.getName());
builder.append(ChatColorType.NORMAL);
builder.append(": GE ");
builder.append(ChatColorType.HIGHLIGHT);
builder.append(StackFormatter.formatNumber(itemPrice));
builder.append(ChatColorType.NORMAL);
builder.append(": OSB ");
builder.append(ChatColorType.HIGHLIGHT);
builder.append(StackFormatter.formatNumber(osbresult.getOverall_average()));
ItemDefinition itemComposition = itemManager.getItemDefinition(itemId); log.debug("Setting response {}", response);
if (itemComposition != null) messageNode.setRuneLiteFormatMessage(response);
{ chatMessageManager.update(messageNode);
int alchPrice = itemManager.getAlchValue(itemId); client.refreshChat();
builder }
.append(ChatColorType.NORMAL)
.append(" HA value ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice));
}
String response = builder.build();
log.debug("Setting response {}", response);
messageNode.setRuneLiteFormatMessage(response);
chatMessageManager.update(messageNode);
client.refreshChat();
})
); );
} }
} }

View File

@@ -29,9 +29,11 @@ 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.ScriptID; import net.runelite.api.ScriptID;
import net.runelite.api.GameState;
import net.runelite.api.VarClientStr; import net.runelite.api.VarClientStr;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
import net.runelite.client.util.Clipboard;
@Singleton @Singleton
class ChatKeyboardListener implements KeyListener class ChatKeyboardListener implements KeyListener
@@ -54,15 +56,45 @@ class ChatKeyboardListener implements KeyListener
@Override @Override
public void keyPressed(KeyEvent e) public void keyPressed(KeyEvent e)
{ {
if (!e.isControlDown() || !chatCommandsConfig.clearShortcuts()) if (!e.isControlDown() || client.getGameState() != GameState.LOGGED_IN)
{ {
return; return;
} }
String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT);
switch (e.getKeyCode()) switch (e.getKeyCode())
{ {
case KeyEvent.VK_C:
if (!chatCommandsConfig.clipboardShortcuts())
{
break;
}
Clipboard.store(input);
break;
case KeyEvent.VK_V:
if (!chatCommandsConfig.clipboardShortcuts())
{
break;
}
final String clipboard = Clipboard.retrieve();
if (clipboard != null && !clipboard.isEmpty())
{
final String replacement = input + clipboard;
clientThread.invoke(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, replacement));
}
break;
case KeyEvent.VK_W: case KeyEvent.VK_W:
String input = client.getVar(VarClientStr.CHATBOX_TYPED_TEXT); if (!chatCommandsConfig.clearShortcuts())
{
break;
}
if (input != null) if (input != null)
{ {
// remove trailing space // remove trailing space
@@ -96,6 +128,12 @@ class ChatKeyboardListener implements KeyListener
client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""); client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, "");
client.runScript(ScriptID.CHAT_PROMPT_INIT); client.runScript(ScriptID.CHAT_PROMPT_INIT);
}); });
if (!chatCommandsConfig.clearShortcuts())
{
break;
}
clientThread.invoke(() -> client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""));
break; break;
} }
} }

View File

@@ -25,13 +25,14 @@
package net.runelite.client.plugins.defaultworld; package net.runelite.client.plugins.defaultworld;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.io.IOException; import io.reactivex.schedulers.Schedulers;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.SessionOpen; import net.runelite.client.events.SessionOpen;
@@ -40,7 +41,6 @@ import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.WorldUtil; import net.runelite.client.util.WorldUtil;
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;
@PluginDescriptor( @PluginDescriptor(
name = "Default World", name = "Default World",
@@ -60,6 +60,9 @@ public class DefaultWorldPlugin extends Plugin
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
@Inject
private ClientThread clientThread;
private final WorldClient worldClient = new WorldClient(); private final WorldClient worldClient = new WorldClient();
private int worldCache; private int worldCache;
private boolean worldChangeRequired; private boolean worldChangeRequired;
@@ -122,39 +125,39 @@ public class DefaultWorldPlugin extends Plugin
return; return;
} }
try worldClient.lookupWorlds()
{ .subscribeOn(Schedulers.io())
final WorldResult worldResult = worldClient.lookupWorlds(); .observeOn(Schedulers.from(clientThread))
.subscribe(
(worldResult) ->
{
if (worldResult == null)
{
return;
}
if (worldResult == null) final World world = worldResult.findWorld(correctedWorld);
{
return;
}
final World world = worldResult.findWorld(correctedWorld); if (world != null)
{
final net.runelite.api.World rsWorld = client.createWorld();
rsWorld.setActivity(world.getActivity());
rsWorld.setAddress(world.getAddress());
rsWorld.setId(world.getId());
rsWorld.setPlayerCount(world.getPlayers());
rsWorld.setLocation(world.getLocation());
rsWorld.setTypes(WorldUtil.toWorldTypes(world.getTypes()));
if (world != null) client.changeWorld(rsWorld);
{ log.debug("Applied new world {}", correctedWorld);
final net.runelite.api.World rsWorld = client.createWorld(); }
rsWorld.setActivity(world.getActivity()); else
rsWorld.setAddress(world.getAddress()); {
rsWorld.setId(world.getId()); log.warn("World {} not found.", correctedWorld);
rsWorld.setPlayerCount(world.getPlayers()); }
rsWorld.setLocation(world.getLocation()); },
rsWorld.setTypes(WorldUtil.toWorldTypes(world.getTypes())); (e) -> log.warn("Error looking up world {}. Error: {}", correctedWorld, e)
);
client.changeWorld(rsWorld);
log.debug("Applied new world {}", correctedWorld);
}
else
{
log.warn("World {} not found.", correctedWorld);
}
}
catch (IOException e)
{
log.warn("Error looking up world {}. Error: {}", correctedWorld, e);
}
} }
private void applyWorld() private void applyWorld()

View File

@@ -370,42 +370,63 @@ public class ExaminePlugin extends Plugin
{ {
int finalQuantity = quantity; int finalQuantity = quantity;
CLIENT.lookupItem(id) CLIENT.lookupItem(id)
.subscribeOn(Schedulers.single()) .subscribeOn(Schedulers.io())
.observeOn(Schedulers.from(clientThread))
.subscribe( .subscribe(
(osbresult) -> (osbresult) ->
clientThread.invoke(() -> {
message
.append(ChatColorType.NORMAL)
.append(" GE ")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(gePrice * finalQuantity));
if (osbresult != null)
{ {
message message
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append(" GE ") .append(" OSB ")
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(gePrice * finalQuantity)); .append(StackFormatter.formatNumber(osbresult.getOverall_average() * finalQuantity));
}
if (osbresult != null) if (finalQuantity > 1)
{ {
message message
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append(" OSB ") .append(" (")
.append(ChatColorType.HIGHLIGHT) .append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(osbresult.getOverall_average() * finalQuantity)); .append(StackFormatter.formatNumber(gePrice))
} .append(ChatColorType.NORMAL)
.append("ea)");
}
if (finalQuantity > 1) message
{ .append(ChatColorType.NORMAL)
message .append(" HA value ")
.append(ChatColorType.NORMAL) .append(ChatColorType.HIGHLIGHT)
.append(" (") .append(StackFormatter.formatNumber(alchPrice * finalQuantity));
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(gePrice)) if (finalQuantity > 1)
.append(ChatColorType.NORMAL) {
.append("ea)"); message
} .append(ChatColorType.NORMAL)
}), .append(" (")
.append(ChatColorType.HIGHLIGHT)
.append(StackFormatter.formatNumber(alchPrice))
.append(ChatColorType.NORMAL)
.append("ea)");
}
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.ITEM_EXAMINE)
.runeLiteFormattedMessage(message.build())
.build());
},
(e) -> log.error(e.toString()) (e) -> log.error(e.toString())
); );
} }
else
if (alchPrice > 0)
{ {
message message
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
@@ -423,12 +444,12 @@ public class ExaminePlugin extends Plugin
.append(ChatColorType.NORMAL) .append(ChatColorType.NORMAL)
.append("ea)"); .append("ea)");
} }
}
chatMessageManager.queue(QueuedMessage.builder() chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.ITEM_EXAMINE) .type(ChatMessageType.ITEM_EXAMINE)
.runeLiteFormattedMessage(message.build()) .runeLiteFormattedMessage(message.build())
.build()); .build());
}
} }
} }

View File

@@ -96,4 +96,15 @@ public interface GrandExchangeConfig extends Config
{ {
return false; return false;
} }
@ConfigItem(
position = 7,
keyName = "enableAfford",
name = "Enable Afford quantity on GE",
description = "Shows the quantity you can buy on the GE"
)
default boolean enableAfford()
{
return true;
}
} }

View File

@@ -48,14 +48,18 @@ import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.GrandExchangeOffer; import net.runelite.api.GrandExchangeOffer;
import net.runelite.api.GrandExchangeOfferState; import net.runelite.api.GrandExchangeOfferState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemDefinition; import net.runelite.api.ItemDefinition;
import static net.runelite.api.ItemID.COINS_995;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry; import net.runelite.api.MenuEntry;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged; import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.GrandExchangeOfferChanged; import net.runelite.api.events.GrandExchangeOfferChanged;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.events.ScriptCallbackEvent;
@@ -99,7 +103,8 @@ public class GrandExchangePlugin extends Plugin
private static final OSBGrandExchangeClient CLIENT = new OSBGrandExchangeClient(); private static final OSBGrandExchangeClient CLIENT = new OSBGrandExchangeClient();
private static final String OSB_GE_TEXT = "<br>OSBuddy Actively traded price: "; private static final String OSB_GE_TEXT = "<br>OSBuddy Actively traded price: ";
private static final String BUY_LIMIT_GE_TEXT = "<br>Buy limit: "; private static final String BUY_LIMIT_GE_TEXT = "Buy limit: ";
private static final String AFFORD_GE_TEXT = "<br>Afford: ";
private static final Gson GSON = new Gson(); private static final Gson GSON = new Gson();
private static final TypeToken<Map<Integer, Integer>> BUY_LIMIT_TOKEN = new TypeToken<Map<Integer, Integer>>() private static final TypeToken<Map<Integer, Integer>> BUY_LIMIT_TOKEN = new TypeToken<Map<Integer, Integer>>()
{ {
@@ -162,6 +167,13 @@ public class GrandExchangePlugin extends Plugin
private GrandExchangeClient grandExchangeClient; private GrandExchangeClient grandExchangeClient;
private int coins = 0;
private int lastAmount = -1;
private int lastItem = -1;
private int osbItem = -1;
private String osbText = "";
private SavedOffer getOffer(int slot) private SavedOffer getOffer(int slot)
{ {
String offer = configManager.getConfiguration("geoffer." + client.getUsername().toLowerCase(), Integer.toString(slot)); String offer = configManager.getConfiguration("geoffer." + client.getUsername().toLowerCase(), Integer.toString(slot));
@@ -186,6 +198,7 @@ public class GrandExchangePlugin extends Plugin
private boolean enableNotifications; private boolean enableNotifications;
private boolean enableOsbPrices; private boolean enableOsbPrices;
private boolean enableGELimits; private boolean enableGELimits;
private boolean enableAfford;
@Provides @Provides
GrandExchangeConfig provideConfig(ConfigManager configManager) GrandExchangeConfig provideConfig(ConfigManager configManager)
@@ -244,7 +257,6 @@ public class GrandExchangePlugin extends Plugin
private void addSubscriptions() private void addSubscriptions()
{ {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage); eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(SessionOpen.class, this, this::onSessionOpen); eventBus.subscribe(SessionOpen.class, this, this::onSessionOpen);
eventBus.subscribe(SessionClose.class, this, this::onSessionClose); eventBus.subscribe(SessionClose.class, this, this::onSessionClose);
@@ -254,7 +266,6 @@ public class GrandExchangePlugin extends Plugin
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged); eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded); eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent); eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
} }
private void onSessionOpen(SessionOpen sessionOpen) private void onSessionOpen(SessionOpen sessionOpen)
@@ -276,6 +287,7 @@ public class GrandExchangePlugin extends Plugin
this.enableNotifications = config.enableNotifications(); this.enableNotifications = config.enableNotifications();
this.enableOsbPrices = config.enableOsbPrices(); this.enableOsbPrices = config.enableOsbPrices();
this.enableGELimits = config.enableGELimits(); this.enableGELimits = config.enableGELimits();
this.enableAfford = config.enableAfford();
} }
private void onSessionClose(SessionClose sessionClose) private void onSessionClose(SessionClose sessionClose)
@@ -465,6 +477,11 @@ public class GrandExchangePlugin extends Plugin
private void onScriptCallbackEvent(ScriptCallbackEvent event) private void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
if (event.getEventName().equals("geBuilt"))
{
rebuildGeText();
}
if (!event.getEventName().equals("setGETitle") || !config.showTotal()) if (!event.getEventName().equals("setGETitle") || !config.showTotal())
{ {
return; return;
@@ -505,7 +522,7 @@ public class GrandExchangePlugin extends Plugin
stringStack[stringStackSize - 1] += titleBuilder.toString(); stringStack[stringStackSize - 1] += titleBuilder.toString();
} }
private void onGameTick(GameTick event) public void rebuildGeText()
{ {
if (grandExchangeText == null || grandExchangeItem == null || grandExchangeItem.isHidden()) if (grandExchangeText == null || grandExchangeItem == null || grandExchangeItem.isHidden())
{ {
@@ -513,52 +530,86 @@ public class GrandExchangePlugin extends Plugin
} }
final Widget geText = grandExchangeText; final Widget geText = grandExchangeText;
final String geTextString = geText.getText();
final int itemId = grandExchangeItem.getItemId(); final int itemId = grandExchangeItem.getItemId();
if (itemId == OFFER_DEFAULT_ITEM_ID || itemId == -1) if (itemId == OFFER_DEFAULT_ITEM_ID || itemId == -1)
{ {
lastAmount = osbItem = lastItem = -1;
// This item is invalid/nothing has been searched for // This item is invalid/nothing has been searched for
return; return;
} }
if (this.enableGELimits && itemGELimits != null && !geTextString.contains(BUY_LIMIT_GE_TEXT)) final int currentItemPrice = client.getVar(Varbits.GRAND_EXCHANGE_PRICE_PER_ITEM);
if (lastItem == itemId && lastAmount == currentItemPrice )
{
return;
}
lastItem = itemId;
lastAmount = currentItemPrice;
String[] texts = geText.getText().split("<br>");
String text = texts[0];
if (this.enableAfford)
{
final ItemContainer itemContainer = client.getItemContainer(InventoryID.INVENTORY);
final Item[] items = itemContainer.getItems();
for (Item item : items)
{
if (item.getId() == COINS_995)
{
coins = item.getQuantity();
break;
}
}
text += AFFORD_GE_TEXT + StackFormatter.formatNumber(coins / currentItemPrice) + " ";
}
if (this.enableGELimits && itemGELimits != null)
{ {
final Integer itemLimit = itemGELimits.get(itemId); final Integer itemLimit = itemGELimits.get(itemId);
// If we have item buy limit, append it // If we have item buy limit, append it
if (itemLimit != null) if (itemLimit != null)
{ {
final String text = geText.getText() + BUY_LIMIT_GE_TEXT + StackFormatter.formatNumber(itemLimit); text += (!this.enableAfford ? "<br>" : "") + BUY_LIMIT_GE_TEXT + StackFormatter.formatNumber(itemLimit);
geText.setText(text);
} }
} }
if (!this.enableOsbPrices || geTextString.contains(OSB_GE_TEXT)) if (!this.enableOsbPrices)
{ {
// OSB prices are disabled or price was already looked up, so no need to set it again geText.setText(text);
return; return;
} }
geText.setText(text + osbText);
log.debug("Looking up OSB item price {}", itemId); log.debug("Looking up OSB item price {}", itemId);
if (osbItem == lastItem)
{
// OSB Item was already looked up
return;
}
osbItem = lastItem;
final String str = text;
executorService.submit(() -> executorService.submit(() ->
{ {
if (geText.getText().contains(OSB_GE_TEXT))
{
// If there are multiple tasks queued and one of them have already added the price
return;
}
CLIENT.lookupItem(itemId) CLIENT.lookupItem(itemId)
.subscribeOn(Schedulers.single()) .subscribeOn(Schedulers.io())
.observeOn(Schedulers.from(clientThread))
.subscribe( .subscribe(
(osbresult) -> (osbresult) ->
clientThread.invoke(() -> {
{ osbText = OSB_GE_TEXT + StackFormatter.formatNumber(osbresult.getOverall_average());
final String text = geText.getText() + OSB_GE_TEXT + StackFormatter.formatNumber(osbresult.getOverall_average()); geText.setText(str + osbText);
geText.setText(text); },
}),
(e) -> log.debug("Error getting price of item {}", itemId, e) (e) -> log.debug("Error getting price of item {}", itemId, e)
); );
}); });
@@ -571,4 +622,4 @@ public class GrandExchangePlugin extends Plugin
log.debug("Loaded {} limits", itemGELimits.size()); log.debug("Loaded {} limits", itemGELimits.size());
return itemGELimits; return itemGELimits;
} }
} }

View File

@@ -896,6 +896,7 @@ public class IdleNotifierPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
} }
@Override @Override

View File

@@ -105,6 +105,7 @@ public class PlayerScouter extends Plugin
private int minimumRisk; private int minimumRisk;
private int minimumValue; private int minimumValue;
private int timeout; private int timeout;
private boolean outputItems;
private static Map<WorldArea, String> getLocationMap() private static Map<WorldArea, String> getLocationMap()
{ {
@@ -165,6 +166,7 @@ public class PlayerScouter extends Plugin
{ {
return; return;
} }
updateConfig(); updateConfig();
} }
@@ -293,7 +295,7 @@ public class PlayerScouter extends Plugin
if (player.getRisk() > this.minimumRisk) if (player.getRisk() > this.minimumRisk)
{ {
Utils.scoutPlayer(player, url, DISCORD_CLIENT, itemManager, client, this.minimumValue); Utils.scoutPlayer(player, url, DISCORD_CLIENT, itemManager, client, this.minimumValue, this.outputItems);
} }
}); });
} }
@@ -322,6 +324,7 @@ public class PlayerScouter extends Plugin
this.overlayEnabled = config.overlayEnabled(); this.overlayEnabled = config.overlayEnabled();
this.timeout = config.timeout(); this.timeout = config.timeout();
this.onlyWildy = config.onlyWildy(); this.onlyWildy = config.onlyWildy();
this.outputItems = config.outputItems();
} }
private boolean checkWildy() private boolean checkWildy()

View File

@@ -56,18 +56,29 @@ public interface PlayerScouterConfig extends Config
keyName = "onlyWildy", keyName = "onlyWildy",
name = "Only Scout in Wildy", name = "Only Scout in Wildy",
description = "This will only scout players in the wilderness.", description = "This will only scout players in the wilderness.",
position = 1 position = 2
) )
default boolean onlyWildy() default boolean onlyWildy()
{ {
return true; return true;
} }
@ConfigItem(
keyName = "outputItems",
name = "Output Items",
description = "This will output all of their risked gear to the webhook.",
position = 3
)
default boolean outputItems()
{
return false;
}
@ConfigItem( @ConfigItem(
keyName = "minimumRisk", keyName = "minimumRisk",
name = "Minimum Risk", name = "Minimum Risk",
description = "Minimum risk for the player to be scouted.", description = "Minimum risk for the player to be scouted.",
position = 2 position = 4
) )
default int minimumRisk() default int minimumRisk()
{ {
@@ -78,7 +89,7 @@ public interface PlayerScouterConfig extends Config
keyName = "minimumValue", keyName = "minimumValue",
name = "Minimum Value", name = "Minimum Value",
description = "Minimum value for the item to be posted on discord.", description = "Minimum value for the item to be posted on discord.",
position = 3 position = 5
) )
default int minimumValue() default int minimumValue()
{ {
@@ -89,7 +100,7 @@ public interface PlayerScouterConfig extends Config
keyName = "timeout", keyName = "timeout",
name = "Timeout", name = "Timeout",
description = "Minimum amount of ticks before the player can be scouted again. (1 tick = 600ms)", description = "Minimum amount of ticks before the player can be scouted again. (1 tick = 600ms)",
position = 4 position = 6
) )
default int timeout() default int timeout()
{ {

View File

@@ -498,7 +498,7 @@ class Utils
return "No Target Detected"; return "No Target Detected";
} }
static void scoutPlayer(PlayerContainer player, HttpUrl url, DiscordClient discordClient, ItemManager itemManager, Client client, int minimumValue) static void scoutPlayer(PlayerContainer player, HttpUrl url, DiscordClient discordClient, ItemManager itemManager, Client client, int minimumValue, boolean outputItems)
{ {
if (player.isScouted()) if (player.isScouted())
{ {
@@ -571,43 +571,46 @@ class Utils
.inline(true) .inline(true)
.build()); .build());
fieldList.add(FieldEmbed.builder() if (outputItems)
.name("Risked Items Sorted by Value")
.value("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
.build());
final int[] items = {0};
player.getRiskedGear().forEach((gear, value) ->
{
if (value <= 0 || value <= minimumValue)
{
items[0]++;
return;
}
ItemStats item = itemManager.getItemStats(gear, false);
if (item == null)
{
log.error("Item is Null: {}", gear);
return;
}
fieldList.add(FieldEmbed.builder()
.name(item.getName())
.value("Value: " + StackFormatter.quantityToRSDecimalStack(value))
.inline(true)
.build());
});
if (items[0] > 0)
{ {
fieldList.add(FieldEmbed.builder() fieldList.add(FieldEmbed.builder()
.name("Items below value: " + minimumValue) .name("Risked Items Sorted by Value")
.value(Integer.toString(items[0])) .value("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
.inline(true)
.build()); .build());
final int[] items = {0};
player.getRiskedGear().forEach((gear, value) ->
{
if (value <= 0 || value <= minimumValue)
{
items[0]++;
return;
}
ItemStats item = itemManager.getItemStats(gear, false);
if (item == null)
{
log.error("Item is Null: {}", gear);
return;
}
fieldList.add(FieldEmbed.builder()
.name(item.getName())
.value("Value: " + StackFormatter.quantityToRSDecimalStack(value))
.inline(true)
.build());
});
if (items[0] > 0)
{
fieldList.add(FieldEmbed.builder()
.name("Items below value: " + minimumValue)
.value(Integer.toString(items[0]))
.inline(true)
.build());
}
} }
message(player.getPlayer().getName(), " ", ICONBASEURL + Objects.requireNonNull(getEntry(player.getGear())).getKey() + ".png", image, fieldList, url, discordClient, color); message(player.getPlayer().getName(), " ", ICONBASEURL + Objects.requireNonNull(getEntry(player.getGear())).getKey() + ".png", image, fieldList, url, discordClient, color);
@@ -695,4 +698,4 @@ class Utils
} }
return s; return s;
} }
} }

View File

@@ -32,10 +32,7 @@ import com.google.inject.Provides;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.Toolkit;
import java.awt.TrayIcon; import java.awt.TrayIcon;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -103,6 +100,7 @@ import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.DrawManager; import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.Clipboard;
import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@@ -247,7 +245,7 @@ public class ScreenshotPlugin extends Plugin
{ {
updateConfig(); updateConfig();
addSubscriptions(); addSubscriptions();
overlayManager.add(screenshotOverlay); overlayManager.add(screenshotOverlay);
SCREENSHOT_DIR.mkdirs(); SCREENSHOT_DIR.mkdirs();
keyManager.registerKeyListener(hotkeyListener); keyManager.registerKeyListener(hotkeyListener);
@@ -855,9 +853,7 @@ public class ScreenshotPlugin extends Plugin
{ {
String link = imageUploadResponse.getData().getLink(); String link = imageUploadResponse.getData().getLink();
StringSelection selection = new StringSelection(link); Clipboard.store(link);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
if (notifyWhenTaken) if (notifyWhenTaken)
{ {
@@ -915,7 +911,7 @@ public class ScreenshotPlugin extends Plugin
updateConfig(); updateConfig();
} }
private void updateConfig() private void updateConfig()
{ {
this.includeFrame = config.includeFrame(); this.includeFrame = config.includeFrame();

View File

@@ -29,8 +29,8 @@ import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import com.google.inject.Provides; import com.google.inject.Provides;
import io.reactivex.schedulers.Schedulers;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.Comparator; import java.util.Comparator;
@@ -502,22 +502,21 @@ public class WorldHopperPlugin extends Plugin
{ {
log.debug("Fetching worlds"); log.debug("Fetching worlds");
try new WorldClient().lookupWorlds()
{ .subscribeOn(Schedulers.io())
WorldResult worldResult = new WorldClient().lookupWorlds(); .subscribe(
(worldResult) ->
if (worldResult != null) {
{ if (worldResult != null)
worldResult.getWorlds().sort(Comparator.comparingInt(World::getId)); {
this.worldResult = worldResult; worldResult.getWorlds().sort(Comparator.comparingInt(World::getId));
this.lastFetch = Instant.now(); this.worldResult = worldResult;
updateList(); this.lastFetch = Instant.now();
} updateList();
} }
catch (IOException ex) },
{ (ex) -> log.warn("Error looking up worlds", ex)
log.warn("Error looking up worlds", ex); );
}
} }
/** /**

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2018, Connor <contact@connor-parks.email>
* 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.client.util;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
public class Clipboard
{
public static String retrieve()
{
Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (contents == null || ! contents.isDataFlavorSupported(DataFlavor.stringFlavor))
{
return null;
}
try
{
return (String) contents.getTransferData(DataFlavor.stringFlavor);
}
catch (UnsupportedFlavorException | IOException ex)
{
return null;
}
}
public static void store(String contents)
{
final StringSelection selection = new StringSelection(contents);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null);
}
}

View File

@@ -26,8 +26,6 @@ package net.runelite.client.util;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@@ -144,8 +142,7 @@ public class LinkBrowser
if (result == JOptionPane.OK_OPTION) if (result == JOptionPane.OK_OPTION)
{ {
final StringSelection stringSelection = new StringSelection(data); Clipboard.store(data);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
} }
}); });
} }

View File

@@ -15,7 +15,7 @@ import org.codehaus.plexus.util.FileUtils;
public class Bootstrap public class Bootstrap
{ {
String buildCommit = "b82c8903c64695d44b255d45b449440e4eaa17ef"; String buildCommit = "6fe334c02648d3f8b38625e3175e3f547d54aa37";
Client client = new Client(); Client client = new Client();
String[] clientJvm9Arguments = new String[]{ String[] clientJvm9Arguments = new String[]{
"-XX:+DisableAttachMechanism", "-XX:+DisableAttachMechanism",
@@ -106,7 +106,7 @@ public class Bootstrap
{ {
try try
{ {
artifacts = new Artifact[43]; artifacts = new Artifact[46];
//Static artifacts //Static artifacts
artifacts[0] = new Artifact(); artifacts[0] = new Artifact();
@@ -301,9 +301,19 @@ public class Bootstrap
artifacts[41].size = "617294"; artifacts[41].size = "617294";
artifacts[43] = new Artifact(); artifacts[43] = new Artifact();
artifacts[43].hash = "21b5cac673a156cd8d6cf9efe15ff267b6353eeb129678aa4b39542683ba0dc2"; artifacts[43].hash = "21b5cac673a156cd8d6cf9efe15ff267b6353eeb129678aa4b39542683ba0dc2";
artifacts[43].name = "rxjava-2.2.10"; artifacts[43].name = "rxjava-2.2.10.jar";
artifacts[43].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[43].name; artifacts[43].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/" + artifacts[43].name;
artifacts[43].size = "2348810"; artifacts[43].size = "2348810";
artifacts[44] = new Artifact();
artifacts[44].hash = "830a08b9d5c20ab8e2033c16fc6ee067e6ffcd0c730f303d648aadfa81210d62";
artifacts[44].name = "rxrelay-2.1.0.jar";
artifacts[44].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/" + artifacts[44].name;
artifacts[44].size = "27750";
artifacts[45] = new Artifact();
artifacts[45].hash = "cc09ab0b140e0d0496c2165d4b32ce24f4d6446c0a26c5dc77b06bdf99ee8fae";
artifacts[45].name = "reactive-streams-1.0.2.jar";
artifacts[45].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/" + artifacts[45].name;
artifacts[45].size = "27750";
//Dynamic artifacts //Dynamic artifacts
artifacts[3] = new Artifact(); artifacts[3] = new Artifact();

View File

@@ -8,5 +8,5 @@ public class Client
String extension = "jar"; String extension = "jar";
String groupId = "net.runelite"; String groupId = "net.runelite";
String properties = ""; String properties = "";
String version = "1.5.29"; String version = "1.5.30";
} }

View File

@@ -3,9 +3,14 @@ package net.runelite.mixins;
import net.runelite.api.Sprite; import net.runelite.api.Sprite;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace;
import net.runelite.rs.api.RSAbstractArchive;
import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSSprite;
@Mixin(RSClient.class) @Mixin(RSClient.class)
public abstract class SpriteMixin implements RSClient public abstract class SpriteMixin implements RSClient
@@ -29,4 +34,23 @@ public abstract class SpriteMixin implements RSClient
{ {
return widgetSpriteOverrides; return widgetSpriteOverrides;
} }
@Copy("loadSprite")
public static RSSprite rs$loadSprite(RSAbstractArchive var0, int var1, int var2)
{
throw new RuntimeException();
}
@Replace("loadSprite")
public static RSSprite rl$loadSprite(RSAbstractArchive var0, int var1, int var2)
{
Sprite sprite = spriteOverrides.get(var1);
if (sprite != null)
{
return (RSSprite) sprite;
}
return rs$loadSprite(var0, var1, var2);
}
} }

View File

@@ -61,8 +61,8 @@ public class Friend extends Buddy {
signature = "(Lhp;IIB)Z", signature = "(Lhp;IIB)Z",
garbageValue = "-3" garbageValue = "-3"
) )
@Export("SpriteBuffer_loadSprite") @Export("doesSpriteExist")
public static boolean SpriteBuffer_loadSprite(AbstractArchive var0, int var1, int var2) { public static boolean doesSpriteExist(AbstractArchive var0, int var1, int var2) {
byte[] var3 = var0.takeFile(var1, var2); byte[] var3 = var0.takeFile(var1, var2);
if (var3 == null) { if (var3 == null) {
return false; return false;

View File

@@ -103,6 +103,6 @@ public final class GameObject {
) )
@Export("loadFont") @Export("loadFont")
public static Font loadFont(AbstractArchive var0, AbstractArchive var1, int var2, int var3) { public static Font loadFont(AbstractArchive var0, AbstractArchive var1, int var2, int var3) {
return !Friend.SpriteBuffer_loadSprite(var0, var2, var3) ? null : WallDecoration.getWorldMapSprite(var1.takeFile(var2, var3)); return !Friend.doesSpriteExist(var0, var2, var3) ? null : WallDecoration.getWorldMapSprite(var1.takeFile(var2, var3));
} }
} }

View File

@@ -172,7 +172,7 @@ public class HealthBarDefinition extends DualNode {
if (var1 != null) { if (var1 != null) {
return var1; return var1;
} else { } else {
var1 = class65.SpriteBuffer_tryCreateSprite(HealthBarDefinition_spritesArchive, this.frontSpriteID, 0); var1 = class65.loadSprite(HealthBarDefinition_spritesArchive, this.frontSpriteID, 0);
if (var1 != null) { if (var1 != null) {
HealthBarDefinition_cachedSprites.put(var1, (long)this.frontSpriteID); HealthBarDefinition_cachedSprites.put(var1, (long)this.frontSpriteID);
} }
@@ -196,7 +196,7 @@ public class HealthBarDefinition extends DualNode {
if (var1 != null) { if (var1 != null) {
return var1; return var1;
} else { } else {
var1 = class65.SpriteBuffer_tryCreateSprite(HealthBarDefinition_spritesArchive, this.backSpriteID, 0); var1 = class65.loadSprite(HealthBarDefinition_spritesArchive, this.backSpriteID, 0);
if (var1 != null) { if (var1 != null) {
HealthBarDefinition_cachedSprites.put(var1, (long)this.backSpriteID); HealthBarDefinition_cachedSprites.put(var1, (long)this.backSpriteID);
} }

View File

@@ -290,7 +290,7 @@ public class HitSplatDefinition extends DualNode {
if (var1 != null) { if (var1 != null) {
return var1; return var1;
} else { } else {
var1 = class65.SpriteBuffer_tryCreateSprite(HitSplatDefinition_spritesArchive, this.field3334, 0); var1 = class65.loadSprite(HitSplatDefinition_spritesArchive, this.field3334, 0);
if (var1 != null) { if (var1 != null) {
HitSplatDefinition_cachedSprites.put(var1, (long)this.field3334); HitSplatDefinition_cachedSprites.put(var1, (long)this.field3334);
} }
@@ -313,7 +313,7 @@ public class HitSplatDefinition extends DualNode {
if (var1 != null) { if (var1 != null) {
return var1; return var1;
} else { } else {
var1 = class65.SpriteBuffer_tryCreateSprite(HitSplatDefinition_spritesArchive, this.field3336, 0); var1 = class65.loadSprite(HitSplatDefinition_spritesArchive, this.field3336, 0);
if (var1 != null) { if (var1 != null) {
HitSplatDefinition_cachedSprites.put(var1, (long)this.field3336); HitSplatDefinition_cachedSprites.put(var1, (long)this.field3336);
} }
@@ -336,7 +336,7 @@ public class HitSplatDefinition extends DualNode {
if (var1 != null) { if (var1 != null) {
return var1; return var1;
} else { } else {
var1 = class65.SpriteBuffer_tryCreateSprite(HitSplatDefinition_spritesArchive, this.field3337, 0); var1 = class65.loadSprite(HitSplatDefinition_spritesArchive, this.field3337, 0);
if (var1 != null) { if (var1 != null) {
HitSplatDefinition_cachedSprites.put(var1, (long)this.field3337); HitSplatDefinition_cachedSprites.put(var1, (long)this.field3337);
} }
@@ -359,7 +359,7 @@ public class HitSplatDefinition extends DualNode {
if (var1 != null) { if (var1 != null) {
return var1; return var1;
} else { } else {
var1 = class65.SpriteBuffer_tryCreateSprite(HitSplatDefinition_spritesArchive, this.field3338, 0); var1 = class65.loadSprite(HitSplatDefinition_spritesArchive, this.field3338, 0);
if (var1 != null) { if (var1 != null) {
HitSplatDefinition_cachedSprites.put(var1, (long)this.field3338); HitSplatDefinition_cachedSprites.put(var1, (long)this.field3338);
} }
@@ -387,7 +387,7 @@ public class HitSplatDefinition extends DualNode {
AbstractArchive var4 = HitSplatDefinition_fontsArchive; AbstractArchive var4 = HitSplatDefinition_fontsArchive;
int var5 = this.fontId; int var5 = this.fontId;
Font var2; Font var2;
if (!Friend.SpriteBuffer_loadSprite(var3, var5, 0)) { if (!Friend.doesSpriteExist(var3, var5, 0)) {
var2 = null; var2 = null;
} else { } else {
var2 = WallDecoration.getWorldMapSprite(var4.takeFile(var5, 0)); var2 = WallDecoration.getWorldMapSprite(var4.takeFile(var5, 0));

View File

@@ -169,8 +169,9 @@ public class PacketBuffer extends Buffer {
signature = "(Lhp;III)Llx;", signature = "(Lhp;III)Llx;",
garbageValue = "-1232611828" garbageValue = "-1232611828"
) )
static IndexedSprite method5474(AbstractArchive var0, int var1, int var2) { @Export("loadIndexedSprite")
if (!Friend.SpriteBuffer_loadSprite(var0, var1, var2)) { static IndexedSprite loadIndexedSprite(AbstractArchive var0, int var1, int var2) {
if (!Friend.doesSpriteExist(var0, var1, var2)) {
return null; return null;
} else { } else {
IndexedSprite var4 = new IndexedSprite(); IndexedSprite var4 = new IndexedSprite();

View File

@@ -64,7 +64,7 @@ public final class TilePaint {
garbageValue = "1591290793" garbageValue = "1591290793"
) )
public static Sprite[] method3062(AbstractArchive var0, int var1, int var2) { public static Sprite[] method3062(AbstractArchive var0, int var1, int var2) {
if (!Friend.SpriteBuffer_loadSprite(var0, var1, var2)) { if (!Friend.doesSpriteExist(var0, var1, var2)) {
return null; return null;
} else { } else {
Sprite[] var4 = new Sprite[class326.SpriteBuffer_spriteCount]; Sprite[] var4 = new Sprite[class326.SpriteBuffer_spriteCount];

View File

@@ -491,13 +491,13 @@ public class Timer {
} else if (Client.titleLoadingStage == 80) { } else if (Client.titleLoadingStage == 80) {
var0 = 0; var0 = 0;
if (Message.compass == null) { if (Message.compass == null) {
Message.compass = class65.SpriteBuffer_tryCreateSprite(Client.archive8, UserComparator6.spriteIds.compass, 0); Message.compass = class65.loadSprite(Client.archive8, UserComparator6.spriteIds.compass, 0);
} else { } else {
++var0; ++var0;
} }
if (UserComparator4.redHintArrowSprite == null) { if (UserComparator4.redHintArrowSprite == null) {
UserComparator4.redHintArrowSprite = class65.SpriteBuffer_tryCreateSprite(Client.archive8, UserComparator6.spriteIds.field3823, 0); UserComparator4.redHintArrowSprite = class65.loadSprite(Client.archive8, UserComparator6.spriteIds.field3823, 0);
} else { } else {
++var0; ++var0;
} }

View File

@@ -1271,7 +1271,7 @@ public class Widget extends Node {
if (var5 != null) { if (var5 != null) {
return var5; return var5;
} else { } else {
var5 = class65.SpriteBuffer_tryCreateSprite(class216.Widget_spritesArchive, var2, 0); var5 = class65.loadSprite(class216.Widget_spritesArchive, var2, 0);
if (var5 == null) { if (var5 == null) {
field2562 = true; field2562 = true;
return null; return null;
@@ -1351,7 +1351,7 @@ public class Widget extends Node {
if (var3 != null) { if (var3 != null) {
return var3; return var3;
} else { } else {
var3 = class65.SpriteBuffer_tryCreateSprite(class216.Widget_spritesArchive, var2, 0); var3 = class65.loadSprite(class216.Widget_spritesArchive, var2, 0);
if (var3 != null) { if (var3 != null) {
Widget_cachedSprites.put(var3, (long)var2); Widget_cachedSprites.put(var3, (long)var2);
} else { } else {

View File

@@ -283,7 +283,7 @@ public class WorldMapElement extends DualNode {
if (var2 != null) { if (var2 != null) {
return var2; return var2;
} else { } else {
var2 = class65.SpriteBuffer_tryCreateSprite(WorldMapElement_archive, var1, 0); var2 = class65.loadSprite(WorldMapElement_archive, var1, 0);
if (var2 != null) { if (var2 != null) {
WorldMapElement_cachedSprites.put(var2, (long)var1); WorldMapElement_cachedSprites.put(var2, (long)var1);
} }

View File

@@ -71,7 +71,7 @@ public class class215 {
public static IndexedSprite loadIndexedSpriteByName(AbstractArchive var0, String var1, String var2) { public static IndexedSprite loadIndexedSpriteByName(AbstractArchive var0, String var1, String var2) {
int var3 = var0.getGroupId(var1); int var3 = var0.getGroupId(var1);
int var4 = var0.getFileId(var3, var2); int var4 = var0.getFileId(var3, var2);
return PacketBuffer.method5474(var0, var3, var4); return PacketBuffer.loadIndexedSprite(var0, var3, var4);
} }
@ObfuscatedName("eg") @ObfuscatedName("eg")

View File

@@ -12,7 +12,7 @@ public class class287 {
int var4 = var0.getGroupId(var2); int var4 = var0.getGroupId(var2);
int var5 = var0.getFileId(var4, var3); int var5 = var0.getFileId(var4, var3);
Font var6; Font var6;
if (!Friend.SpriteBuffer_loadSprite(var0, var4, var5)) { if (!Friend.doesSpriteExist(var0, var4, var5)) {
var6 = null; var6 = null;
} else { } else {
var6 = WallDecoration.getWorldMapSprite(var1.takeFile(var4, var5)); var6 = WallDecoration.getWorldMapSprite(var1.takeFile(var4, var5));

View File

@@ -26,7 +26,7 @@ public final class class289 {
garbageValue = "1777014825" garbageValue = "1777014825"
) )
public static IndexedSprite[] method5281(AbstractArchive var0, int var1, int var2) { public static IndexedSprite[] method5281(AbstractArchive var0, int var1, int var2) {
if (!Friend.SpriteBuffer_loadSprite(var0, var1, var2)) { if (!Friend.doesSpriteExist(var0, var1, var2)) {
return null; return null;
} else { } else {
IndexedSprite[] var4 = new IndexedSprite[class326.SpriteBuffer_spriteCount]; IndexedSprite[] var4 = new IndexedSprite[class326.SpriteBuffer_spriteCount];

View File

@@ -69,9 +69,9 @@ public class class65 extends RouteStrategy {
signature = "(Lhp;III)Lly;", signature = "(Lhp;III)Lly;",
garbageValue = "300652258" garbageValue = "300652258"
) )
@Export("SpriteBuffer_tryCreateSprite") @Export("loadSprite")
public static Sprite SpriteBuffer_tryCreateSprite(AbstractArchive var0, int var1, int var2) { public static Sprite loadSprite(AbstractArchive var0, int var1, int var2) {
if (!Friend.SpriteBuffer_loadSprite(var0, var1, var2)) { if (!Friend.doesSpriteExist(var0, var1, var2)) {
return null; return null;
} else { } else {
Sprite var4 = new Sprite(); Sprite var4 = new Sprite();