Merge branch 'blue-api' into runelite

This commit is contained in:
TheRealNull
2021-01-04 01:52:46 -05:00
8 changed files with 52 additions and 14 deletions

View File

@@ -2071,4 +2071,6 @@ public interface Client extends GameShell
Widget getWidget(int param1); Widget getWidget(int param1);
Widget getScriptActiveWidget(); Widget getScriptActiveWidget();
ScriptEvent createScriptEvent(Object[] args);
} }

View File

@@ -40,13 +40,19 @@ public interface ScriptEvent
String NAME = "event_opbase"; String NAME = "event_opbase";
/** /**
* Gets the widget of the event. * Gets the widget the {@link #WIDGET_ID} and {@link #WIDGET_INDEX} args
* * are substituted with
* @return the widget
* @see Widget
*/ */
Widget getSource(); Widget getSource();
/**
* Sets the widget the {@link #WIDGET_ID} and {@link #WIDGET_INDEX} args
* are substituted with. This is useful for running widget listeners
*
* @see Widget#getOnLoadListener()
*/
ScriptEvent setSource(Widget widget);
/** /**
* Gets the menu index of the event * Gets the menu index of the event
* *
@@ -80,4 +86,11 @@ public interface ScriptEvent
* @return * @return
*/ */
int getTypedKeyChar(); int getTypedKeyChar();
/**
* Executes a cs2 script specified by this event
*
* This method must be ran on the client thread and is not reentrant
*/
void run();
} }

View File

@@ -25,15 +25,16 @@
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Value;
import net.runelite.api.Nameable;
/** /**
* An event where a request to remove a friend is sent to the server. * An event trigger when a player is removed from the friend or ignore list.
*/ */
@Value @Value
public class RemovedFriend implements Event public class RemovedFriend
{ {
/** /**
* The name of the removed friend. * The removed friend or ignore entry
*/ */
String name; private final Nameable nameable;
} }

View File

@@ -85,6 +85,7 @@ import net.runelite.api.Player;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.PlayerChanged; import net.runelite.api.events.PlayerChanged;
import net.runelite.api.events.UsernameChanged; import net.runelite.api.events.UsernameChanged;
import net.runelite.api.events.WorldChanged;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import net.runelite.client.account.AccountSession; import net.runelite.client.account.AccountSession;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
@@ -1042,6 +1043,12 @@ public class ConfigManager
updateRSProfile(); updateRSProfile();
} }
@Subscribe
private void onWorldChanged(WorldChanged ev)
{
updateRSProfile();
}
@Subscribe @Subscribe
private void onPlayerChanged(PlayerChanged ev) private void onPlayerChanged(PlayerChanged ev)
{ {

View File

@@ -69,7 +69,6 @@ public class ExternalPluginClient
.newBuilder() .newBuilder()
.addPathSegments("manifest.js") .addPathSegments("manifest.js")
.build(); .build();
System.out.println(manifest.uri());
try (Response res = okHttpClient.newCall(new Request.Builder().url(manifest).build()).execute()) try (Response res = okHttpClient.newCall(new Request.Builder().url(manifest).build()).execute())
{ {
if (res.code() != 200) if (res.code() != 200)

View File

@@ -132,6 +132,14 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
{ {
addZoomTooltip(sideSlider); addZoomTooltip(sideSlider);
} }
Widget settingsInit = client.getWidget(WidgetInfo.SETTINGS_INIT);
if (settingsInit != null)
{
client.createScriptEvent(settingsInit.getOnLoadListener())
.setSource(settingsInit)
.run();
}
}); });
} }
@@ -152,6 +160,14 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
{ {
sideSlider.setOnMouseRepeatListener((Object[]) null); sideSlider.setOnMouseRepeatListener((Object[]) null);
} }
Widget settingsInit = client.getWidget(WidgetInfo.SETTINGS_INIT);
if (settingsInit != null)
{
client.createScriptEvent(settingsInit.getOnLoadListener())
.setSource(settingsInit)
.run();
}
}); });
} }

View File

@@ -327,7 +327,7 @@ public class FriendNotesPlugin extends Plugin
public void onRemovedFriend(RemovedFriend event) public void onRemovedFriend(RemovedFriend event)
{ {
// Delete a friend's note if they are removed // Delete a friend's note if they are removed
final String displayName = Text.toJagexName(event.getName()); final String displayName = Text.toJagexName(event.getNameable().getName());
log.debug("Remove friend: '{}'", displayName); log.debug("Remove friend: '{}'", displayName);
setFriendNote(displayName, null); setFriendNote(displayName, null);
} }

View File

@@ -19,7 +19,7 @@ public abstract class RSFriendSystemMixin implements RSFriendSystem
@Inject @Inject
public void rl$removeFriend(String friendName) public void rl$removeFriend(String friendName)
{ {
RemovedFriend removedFriend = new RemovedFriend(friendName); RemovedFriend removedFriend = new RemovedFriend(client.getFriendManager().getFriendContainer().findByName(friendName));
client.getCallbacks().post(removedFriend); client.getCallbacks().post(removedFriend);
} }