mixins: Add FriendAdded event

* added onAddedFriend() event

* renamed events to FriendAdded and FriendRemoved
This commit is contained in:
Visne
2019-07-08 17:34:25 +02:00
committed by Lucwousin
parent 9a98431ddb
commit a32c667251
5 changed files with 32 additions and 8 deletions

View File

@@ -0,0 +1,15 @@
package net.runelite.api.events;
import lombok.Value;
/**
* An event where a request to add a friend is sent to the server.
*/
@Value
public class FriendAdded
{
/**
* The name of the added friend.
*/
private final String name;
}

View File

@@ -30,7 +30,7 @@ import lombok.Value;
* An event where a request to remove a friend is sent to the server.
*/
@Value
public class RemovedFriend
public class FriendRemoved
{
/**
* The name of the removed friend.

View File

@@ -43,7 +43,7 @@ import net.runelite.api.Nameable;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.NameableNameChanged;
import net.runelite.api.events.RemovedFriend;
import net.runelite.api.events.FriendRemoved;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -250,7 +250,7 @@ public class FriendNotesPlugin extends Plugin
}
@Subscribe
public void onRemovedFriend(RemovedFriend event)
public void onFriendRemoved(FriendRemoved event)
{
// Delete a friend's note if they are removed
final String displayName = Text.toJagexName(event.getName());

View File

@@ -30,7 +30,7 @@ import net.runelite.api.Nameable;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.api.events.NameableNameChanged;
import net.runelite.api.events.RemovedFriend;
import net.runelite.api.events.FriendRemoved;
import net.runelite.api.events.WidgetMenuOptionClicked;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager;
@@ -128,7 +128,7 @@ public class FriendTaggingPlugin extends Plugin
}
@Subscribe
public void onRemovedFriend(RemovedFriend event)
public void onFriendRemoved(FriendRemoved event)
{
final String displayName = event.getName().trim().toLowerCase();
deleteTag(displayName);

View File

@@ -1,6 +1,7 @@
package net.runelite.mixins;
import net.runelite.api.events.RemovedFriend;
import net.runelite.api.events.FriendAdded;
import net.runelite.api.events.FriendRemoved;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin;
@@ -18,7 +19,15 @@ public abstract class RSFriendSystemMixin implements RSFriendSystem
@Inject
public void rl$removeFriend(String friendName)
{
RemovedFriend removedFriend = new RemovedFriend(friendName);
client.getCallbacks().post(removedFriend);
FriendRemoved friendRemoved = new FriendRemoved(friendName);
client.getCallbacks().post(friendRemoved);
}
@MethodHook("addFriend")
@Inject
public void rl$addFriend(String friendName)
{
FriendAdded friendAdded = new FriendAdded(friendName);
client.getCallbacks().post(friendAdded);
}
}