Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2020-02-21 02:08:47 +01:00
12 changed files with 311 additions and 25 deletions

View File

@@ -27,7 +27,7 @@ object ProjectVersions {
const val launcherVersion = "2.0.4" const val launcherVersion = "2.0.4"
const val rlVersion = "1.6.7" const val rlVersion = "1.6.7"
const val openosrsVersion = "3.0.3" const val openosrsVersion = "3.0.4"
const val rsversion = 188 const val rsversion = 188
const val cacheversion = 165 const val cacheversion = 165

0
gradlew vendored Executable file → Normal file
View File

View File

@@ -1985,4 +1985,19 @@ public interface Client extends GameShell
void setMouseIdleTicks(int cycles); void setMouseIdleTicks(int cycles);
void setKeyboardIdleTicks(int cycles); void setKeyboardIdleTicks(int cycles);
/**
* Sets the result count for GE search
*/
void setGeSearchResultCount(int count);
/**
* Sets the array of item ids for GE search
*/
void setGeSearchResultIds(short[] ids);
/**
* Sets the starting index in the item id array for GE search
*/
void setGeSearchResultIndex(int index);
} }

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2019, Ron Young <https://github.com/raiyni>
* 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.events;
import lombok.Data;
/**
* An event where the Grand Exchange has been searched.
*/
@Data
public class GrandExchangeSearched implements Event
{
/**
* Whether or not the event has been consumed by a subscriber.
*/
private boolean consumed;
/**
* Marks the event as having been consumed.
* <p>
* Setting this state indicates that a plugin has set the GE
* search results and that the event will not be passed on
* for handling by vanilla client code.
*/
public void consume()
{
this.consumed = true;
}
}

View File

@@ -63,6 +63,8 @@ import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.FlashNotification; import net.runelite.client.config.FlashNotification;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.NotificationFired;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.util.OSType; import net.runelite.client.util.OSType;
@@ -106,6 +108,7 @@ public class Notifier
private final ClientUI clientUI; private final ClientUI clientUI;
private final ScheduledExecutorService executorService; private final ScheduledExecutorService executorService;
private final ChatMessageManager chatMessageManager; private final ChatMessageManager chatMessageManager;
private final EventBus eventBus;
private final Path notifyIconPath; private final Path notifyIconPath;
private final boolean terminalNotifierAvailable; private final boolean terminalNotifierAvailable;
private Instant flashStart; private Instant flashStart;
@@ -117,13 +120,15 @@ public class Notifier
final Client client, final Client client,
final RuneLiteConfig runeliteConfig, final RuneLiteConfig runeliteConfig,
final ScheduledExecutorService executorService, final ScheduledExecutorService executorService,
final ChatMessageManager chatMessageManager) final ChatMessageManager chatMessageManager,
final EventBus eventBus)
{ {
this.client = client; this.client = client;
this.clientUI = clientUI; this.clientUI = clientUI;
this.runeLiteConfig = runeliteConfig; this.runeLiteConfig = runeliteConfig;
this.executorService = executorService; this.executorService = executorService;
this.chatMessageManager = chatMessageManager; this.chatMessageManager = chatMessageManager;
this.eventBus = eventBus;
this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png"); this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png");
// First check if we are running in launcher // First check if we are running in launcher
@@ -139,6 +144,8 @@ public class Notifier
public void notify(String message, TrayIcon.MessageType type) public void notify(String message, TrayIcon.MessageType type)
{ {
eventBus.post(NotificationFired.class, new NotificationFired(message, type));
if (!runeLiteConfig.sendNotificationsWhenFocused() && clientUI.isFocused()) if (!runeLiteConfig.sendNotificationsWhenFocused() && clientUI.isFocused())
{ {
return; return;

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2020, Trevor <https://github.com/Trevor159>
* 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.events;
import java.awt.TrayIcon;
import lombok.Value;
import net.runelite.api.events.Event;
@Value
public class NotificationFired implements Event
{
final String message;
final TrayIcon.MessageType type;
}

View File

@@ -26,10 +26,14 @@
package net.runelite.client.game; package net.runelite.client.game;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -40,6 +44,7 @@ import lombok.extern.slf4j.Slf4j;
public class ItemVariationMapping public class ItemVariationMapping
{ {
private static Map<Integer, Integer> MAPPINGS; private static Map<Integer, Integer> MAPPINGS;
private static Multimap<Integer, Integer> INVERTED_MAPPINGS;
/** /**
* Get base item id for provided variation item id. * Get base item id for provided variation item id.
@@ -52,11 +57,23 @@ public class ItemVariationMapping
return MAPPINGS.getOrDefault(itemId, itemId); return MAPPINGS.getOrDefault(itemId, itemId);
} }
/**
* Get item ids for provided variation item id.
*
* @param itemId the item id
* @return the item ids
*/
public static Collection<Integer> getVariations(int itemId)
{
return INVERTED_MAPPINGS.asMap().getOrDefault(itemId, Collections.singletonList(itemId));
}
static void load() throws IOException static void load() throws IOException
{ {
try (JsonReader reader = new JsonReader(new InputStreamReader(ItemVariationMapping.class.getResourceAsStream("/item_variations.min.json"), StandardCharsets.UTF_8))) try (JsonReader reader = new JsonReader(new InputStreamReader(ItemVariationMapping.class.getResourceAsStream("/item_variations.min.json"), StandardCharsets.UTF_8)))
{ {
ImmutableMap.Builder<Integer, Integer> builder = ImmutableMap.builderWithExpectedSize(5039); ImmutableMap.Builder<Integer, Integer> builder = ImmutableMap.builderWithExpectedSize(5039);
ImmutableMultimap.Builder<Integer, Integer> invertedBuilder = new ImmutableMultimap.Builder<>();
reader.beginObject(); reader.beginObject();
while (reader.hasNext()) while (reader.hasNext())
@@ -68,16 +85,20 @@ public class ItemVariationMapping
int base = reader.nextInt(); int base = reader.nextInt();
while (reader.hasNext()) while (reader.hasNext())
{ {
builder.put( final int id = reader.nextInt();
reader.nextInt(),
base builder.put(id, base);
); invertedBuilder.put(base, id);
} }
invertedBuilder.put(base, base);
reader.endArray(); reader.endArray();
} }
reader.endObject(); reader.endObject();
INVERTED_MAPPINGS = invertedBuilder.build();
MAPPINGS = builder.build(); MAPPINGS = builder.build();
} }
} }

View File

@@ -382,9 +382,13 @@ class ExternalPluginManager
Plugin plugin; Plugin plugin;
try try
{ {
plugin = clazz.newInstance(); plugin = clazz.getDeclaredConstructor().newInstance();
} }
catch (InstantiationException | IllegalAccessException ex) catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{ {
throw new PluginInstantiationException(ex); throw new PluginInstantiationException(ex);
} }

View File

@@ -164,26 +164,39 @@ public class PluginManager
public Config getPluginConfigProxy(Plugin plugin) public Config getPluginConfigProxy(Plugin plugin)
{ {
final Injector injector = plugin.getInjector(); try
for (Key<?> key : injector.getAllBindings().keySet())
{ {
Class<?> type = key.getTypeLiteral().getRawType(); final Injector injector = plugin.getInjector();
if (Config.class.isAssignableFrom(type))
for (Key<?> key : injector.getAllBindings().keySet())
{ {
return (Config) injector.getInstance(key); Class<?> type = key.getTypeLiteral().getRawType();
if (Config.class.isAssignableFrom(type))
{
return (Config) injector.getInstance(key);
}
} }
} }
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable e)
{
log.warn("Unable to get plugin config", e);
}
return null; return null;
} }
private List<Config> getPluginConfigProxies() public List<Config> getPluginConfigProxies(Collection<Plugin> plugins)
{ {
List<Injector> injectors = new ArrayList<>(); List<Injector> injectors = new ArrayList<>();
injectors.add(RuneLite.getInjector()); if (plugins == null)
getPlugins().forEach(pl -> injectors.add(pl.getInjector())); {
injectors.add(RuneLite.getInjector());
plugins = getPlugins();
}
plugins.forEach(pl -> injectors.add(pl.getInjector()));
List<Config> list = new ArrayList<>(); List<Config> list = new ArrayList<>();
for (Injector injector : injectors) for (Injector injector : injectors)
{ {
@@ -197,15 +210,25 @@ public class PluginManager
} }
} }
} }
return list; return list;
} }
public void loadDefaultPluginConfiguration() public void loadDefaultPluginConfiguration()
{ {
for (Object config : getPluginConfigProxies()) try
{ {
configManager.setDefaultConfiguration(config, false); for (Object config : getPluginConfigProxies(plugins))
{
configManager.setDefaultConfiguration(config, false);
}
}
catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{
log.warn("Unable to reset plugin configuration", ex);
} }
} }
@@ -409,7 +432,11 @@ public class PluginManager
schedule(plugin); schedule(plugin);
eventBus.post(PluginChanged.class, new PluginChanged(plugin, true)); eventBus.post(PluginChanged.class, new PluginChanged(plugin, true));
} }
catch (Exception ex) catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{ {
throw new PluginInstantiationException(ex); throw new PluginInstantiationException(ex);
} }
@@ -484,9 +511,13 @@ public class PluginManager
Plugin plugin; Plugin plugin;
try try
{ {
plugin = clazz.newInstance(); plugin = clazz.getDeclaredConstructor().newInstance();
} }
catch (InstantiationException | IllegalAccessException ex) catch (ThreadDeath e)
{
throw e;
}
catch (Throwable ex)
{ {
throw new PluginInstantiationException(ex); throw new PluginInstantiationException(ex);
} }

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 2020, Jordan Atwood <jordan.atwood423@gmail.com>
* 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.time.Duration;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalUnit;
import lombok.Getter;
import net.runelite.api.Constants;
@Getter
public enum RSTimeUnit implements TemporalUnit
{
CLIENT_TICKS("Client tick", Duration.ofMillis(Constants.CLIENT_TICK_LENGTH)),
GAME_TICKS("Game tick", Duration.ofMillis(Constants.GAME_TICK_LENGTH)),
;
private final String name;
private final Duration duration;
RSTimeUnit(String name, Duration estimatedDuration)
{
this.name = name;
duration = estimatedDuration;
}
@Override
public boolean isDurationEstimated()
{
return false;
}
@Override
public boolean isDateBased()
{
return false;
}
@Override
public boolean isTimeBased()
{
return true;
}
@Override
public boolean isSupportedBy(Temporal temporal)
{
return temporal.isSupported(this);
}
@Override
public <R extends Temporal> R addTo(R temporal, long amount)
{
return (R) temporal.plus(amount, this);
}
@Override
public long between(Temporal temporal1Inclusive, Temporal temporal2Exclusive)
{
return temporal1Inclusive.until(temporal2Exclusive, this);
}
@Override
public String toString()
{
return name + " (" + duration.toMillis() + "ms)";
}
}

View File

@@ -76,6 +76,7 @@ import net.runelite.api.events.ClientTick;
import net.runelite.api.events.DraggingWidgetChanged; import net.runelite.api.events.DraggingWidgetChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GrandExchangeOfferChanged; import net.runelite.api.events.GrandExchangeOfferChanged;
import net.runelite.api.events.GrandExchangeSearched;
import net.runelite.api.events.Menu; import net.runelite.api.events.Menu;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOpened; import net.runelite.api.events.MenuOpened;
@@ -1172,6 +1173,23 @@ public abstract class RSClientMixin implements RSClient
} }
} }
@Copy("findItemDefinitions")
public static void rs$findItemDefinitions(String var0, boolean var1)
{
throw new RuntimeException();
}
@Replace("findItemDefinitions")
public static void rl$findItemDefinitions(String var0, boolean var1)
{
GrandExchangeSearched event = new GrandExchangeSearched();
client.getCallbacks().post(GrandExchangeSearched.class, event);
if (!event.isConsumed())
{
rs$findItemDefinitions(var0, var1);
}
}
@Inject @Inject
@FieldHook("grandExchangeOffers") @FieldHook("grandExchangeOffers")
public static void onGrandExchangeOffersChanged(int idx) public static void onGrandExchangeOffersChanged(int idx)

View File

@@ -464,6 +464,18 @@ public interface RSClient extends RSGameShell, Client
@Import("grandExchangeOffers") @Import("grandExchangeOffers")
RSGrandExchangeOffer[] getGrandExchangeOffers(); RSGrandExchangeOffer[] getGrandExchangeOffers();
@Import("foundItemIdCount")
@Override
void setGeSearchResultCount(int count);
@Import("foundItemIds")
@Override
void setGeSearchResultIds(short[] ids);
@Import("foundItemIndex")
@Override
void setGeSearchResultIndex(int index);
@Import("isMenuOpen") @Import("isMenuOpen")
@Override @Override
boolean isMenuOpen(); boolean isMenuOpen();