project: wrap up loose ends in api, upstream to fix the broken things

This commit is contained in:
TheRealNull
2021-01-04 01:52:35 -05:00
parent 02b856556c
commit d62af89798
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 getScriptActiveWidget();
ScriptEvent createScriptEvent(Object[] args);
}

View File

@@ -40,13 +40,19 @@ public interface ScriptEvent
String NAME = "event_opbase";
/**
* Gets the widget of the event.
*
* @return the widget
* @see Widget
* Gets the widget the {@link #WIDGET_ID} and {@link #WIDGET_INDEX} args
* are substituted with
*/
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
*
@@ -80,4 +86,11 @@ public interface ScriptEvent
* @return
*/
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;
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
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.events.PlayerChanged;
import net.runelite.api.events.UsernameChanged;
import net.runelite.api.events.WorldChanged;
import net.runelite.client.RuneLite;
import net.runelite.client.account.AccountSession;
import net.runelite.client.eventbus.EventBus;
@@ -1041,7 +1042,13 @@ public class ConfigManager
{
updateRSProfile();
}
@Subscribe
private void onWorldChanged(WorldChanged ev)
{
updateRSProfile();
}
@Subscribe
private void onPlayerChanged(PlayerChanged ev)
{

View File

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

View File

@@ -132,6 +132,14 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener
{
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);
}
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)
{
// 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);
setFriendNote(displayName, null);
}

View File

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