Merge pull request #1155 from Owain94/eventbus-double-sub
eventbus: event interface & prevent double subscribing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
description = 'Web API'
|
||||
dependencies {
|
||||
implementation project(':runelite-api')
|
||||
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.0.1'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.26'
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
*/
|
||||
package net.runelite.http.api.ws;
|
||||
|
||||
public class WebsocketMessage
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
public class WebsocketMessage implements Event
|
||||
{
|
||||
protected boolean _party;
|
||||
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
*/
|
||||
package net.runelite.http.api.ws.messages;
|
||||
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
|
||||
/**
|
||||
* Called after a successful login to the server
|
||||
* @author Adam
|
||||
*/
|
||||
public class LoginResponse extends WebsocketMessage
|
||||
public class LoginResponse extends WebsocketMessage implements Event
|
||||
{
|
||||
private String username;
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@ package net.runelite.http.api.ws.messages.party;
|
||||
import java.util.UUID;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Join extends WebsocketMessage
|
||||
public class Join extends WebsocketMessage implements Event
|
||||
{
|
||||
private final UUID partyId;
|
||||
private final String name;
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
*/
|
||||
package net.runelite.http.api.ws.messages.party;
|
||||
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
|
||||
public class Part extends WebsocketMessage
|
||||
public class Part extends WebsocketMessage implements Event
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package net.runelite.http.api.ws.messages.party;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class PartyMemberMessage extends PartyMessage
|
||||
public abstract class PartyMemberMessage extends PartyMessage implements Event
|
||||
{
|
||||
private UUID memberId;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
*/
|
||||
package net.runelite.http.api.ws.messages.party;
|
||||
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
|
||||
public abstract class PartyMessage extends WebsocketMessage
|
||||
public abstract class PartyMessage extends WebsocketMessage implements Event
|
||||
{
|
||||
public PartyMessage()
|
||||
{
|
||||
|
||||
@@ -27,11 +27,12 @@ package net.runelite.http.api.ws.messages.party;
|
||||
import java.util.UUID;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserJoin extends WebsocketMessage
|
||||
public class UserJoin extends WebsocketMessage implements Event
|
||||
{
|
||||
private final UUID memberId;
|
||||
private final UUID partyId;
|
||||
|
||||
@@ -27,11 +27,12 @@ package net.runelite.http.api.ws.messages.party;
|
||||
import java.util.UUID;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserPart extends WebsocketMessage
|
||||
public class UserPart extends WebsocketMessage implements Event
|
||||
{
|
||||
private final UUID memberId;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@ package net.runelite.http.api.ws.messages.party;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserSync extends PartyMemberMessage
|
||||
public class UserSync extends PartyMemberMessage implements Event
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.runelite.api.events;
|
||||
|
||||
import net.runelite.api.Actor;
|
||||
import lombok.Data;
|
||||
import net.runelite.api.Actor;
|
||||
|
||||
/**
|
||||
* An event where the {@link Actor} has changed animations.
|
||||
@@ -18,7 +17,7 @@ import net.runelite.api.Actor;
|
||||
* @see net.runelite.api.AnimationID
|
||||
*/
|
||||
@Data
|
||||
public class AnimationChanged
|
||||
public class AnimationChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The actor that has entered a new animation.
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AreaSoundEffectPlayed
|
||||
public class AreaSoundEffectPlayed implements Event
|
||||
{
|
||||
private int soundId;
|
||||
private int sceneX;
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BeforeMenuRender
|
||||
public class BeforeMenuRender implements Event
|
||||
{
|
||||
private boolean consumed;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
/**
|
||||
* Posted at the start of every frame
|
||||
*/
|
||||
public class BeforeRender
|
||||
public class BeforeRender implements Event
|
||||
{
|
||||
public static final BeforeRender INSTANCE = new BeforeRender();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import lombok.Data;
|
||||
* retrieve the newly boosted skill level.
|
||||
*/
|
||||
@Data
|
||||
public class BoostedLevelChanged
|
||||
public class BoostedLevelChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The skill that has had its level modified.
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
/**
|
||||
* an event posted when a cannonball is fired
|
||||
*/
|
||||
public class CannonballFired
|
||||
public class CannonballFired implements Event
|
||||
{
|
||||
public static final CannonballFired INSTANCE = new CannonballFired();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
/**
|
||||
* An event posted when the canvas size might have changed.
|
||||
*/
|
||||
public class CanvasSizeChanged
|
||||
public class CanvasSizeChanged implements Event
|
||||
{
|
||||
public static final CanvasSizeChanged INSTANCE = new CanvasSizeChanged();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatMessage
|
||||
public class ChatMessage implements Event
|
||||
{
|
||||
/**
|
||||
* The underlying MessageNode for the message.
|
||||
|
||||
@@ -30,7 +30,7 @@ import lombok.Value;
|
||||
* An event where the client has joined or left a clan chat.
|
||||
*/
|
||||
@Value
|
||||
public class ClanChanged
|
||||
public class ClanChanged implements Event
|
||||
{
|
||||
/**
|
||||
* Whether or not the client is now in a clan chat.
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.runelite.api.ClanMember;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ClanMemberJoined
|
||||
public class ClanMemberJoined implements Event
|
||||
{
|
||||
/**
|
||||
* The ClanMember that joined
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.runelite.api.ClanMember;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ClanMemberLeft
|
||||
public class ClanMemberLeft implements Event
|
||||
{
|
||||
/**
|
||||
* The ClanMember that left
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
/**
|
||||
* Posted every client tick
|
||||
*/
|
||||
public class ClientTick
|
||||
public class ClientTick implements Event
|
||||
{
|
||||
public static final ClientTick INSTANCE = new ClientTick();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import lombok.Value;
|
||||
* will set command to "" and arguments to ["hello", "world!"].
|
||||
*/
|
||||
@Value
|
||||
public class CommandExecuted
|
||||
public class CommandExecuted implements Event
|
||||
{
|
||||
/**
|
||||
* The name of the command entered.
|
||||
|
||||
@@ -30,7 +30,7 @@ import lombok.Data;
|
||||
* An event where a configuration entry has been modified.
|
||||
*/
|
||||
@Data
|
||||
public class ConfigChanged
|
||||
public class ConfigChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The parent group for the key.
|
||||
|
||||
@@ -33,7 +33,7 @@ import lombok.Data;
|
||||
* has been modified.
|
||||
*/
|
||||
@Data
|
||||
public class DecorativeObjectChanged
|
||||
public class DecorativeObjectChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -33,7 +33,7 @@ import lombok.Data;
|
||||
* is removed.
|
||||
*/
|
||||
@Data
|
||||
public class DecorativeObjectDespawned
|
||||
public class DecorativeObjectDespawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link DecorativeObject} is attached to a {@link Tile}.
|
||||
*/
|
||||
@Data
|
||||
public class DecorativeObjectSpawned
|
||||
public class DecorativeObjectSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* the cursor.
|
||||
*/
|
||||
@Data
|
||||
public class DraggingWidgetChanged
|
||||
public class DraggingWidgetChanged implements Event
|
||||
{
|
||||
/**
|
||||
* Whether a widget is currently being dragged.
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.runelite.api.events;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DynamicObjectAnimationChanged
|
||||
public class DynamicObjectAnimationChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The object that has entered a new animation.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.runelite.api.events;
|
||||
|
||||
public interface Event
|
||||
{
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where the experience level of a {@link Skill} has been modified.
|
||||
*/
|
||||
@Data
|
||||
public class ExperienceChanged
|
||||
public class ExperienceChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The modified skill.
|
||||
|
||||
@@ -37,7 +37,7 @@ import lombok.Data;
|
||||
* </ul>
|
||||
*/
|
||||
@Data
|
||||
public class FocusChanged
|
||||
public class FocusChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The new focus state.
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Value;
|
||||
* An event where a request to add a friend is sent to the server.
|
||||
*/
|
||||
@Value
|
||||
public class FriendAdded
|
||||
public class FriendAdded implements Event
|
||||
{
|
||||
/**
|
||||
* The name of the added friend.
|
||||
|
||||
@@ -30,7 +30,7 @@ import lombok.Value;
|
||||
* An event where a request to remove a friend is sent to the server.
|
||||
*/
|
||||
@Value
|
||||
public class FriendRemoved
|
||||
public class FriendRemoved implements Event
|
||||
{
|
||||
/**
|
||||
* The name of the removed friend.
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.runelite.api.Tile;
|
||||
* An event where a {@link GameObject} on a {@link Tile} has been replaced.
|
||||
*/
|
||||
@Data
|
||||
public class GameObjectChanged
|
||||
public class GameObjectChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link GameObject} on a {@link Tile} is removed.
|
||||
*/
|
||||
@Data
|
||||
public class GameObjectDespawned
|
||||
public class GameObjectDespawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link GameObject} is added to a {@link Tile}.
|
||||
*/
|
||||
@Data
|
||||
public class GameObjectSpawned
|
||||
public class GameObjectSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* An event where the clients game state has changed.
|
||||
*/
|
||||
@Data
|
||||
public class GameStateChanged
|
||||
public class GameStateChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The new game state.
|
||||
|
||||
@@ -41,7 +41,7 @@ package net.runelite.api.events;
|
||||
* Note that occurrences that take place purely on the client, such as right
|
||||
* click menus, are independent of the game tick.
|
||||
*/
|
||||
public class GameTick
|
||||
public class GameTick implements Event
|
||||
{
|
||||
public static final GameTick INSTANCE = new GameTick();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import lombok.Data;
|
||||
* can change into.
|
||||
*/
|
||||
@Data
|
||||
public class GrandExchangeOfferChanged
|
||||
public class GrandExchangeOfferChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The offer that has been modified.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Value;
|
||||
* An event where a new {@link GraphicsObject} has been created.
|
||||
*/
|
||||
@Value
|
||||
public class GraphicsObjectCreated
|
||||
public class GraphicsObjectCreated implements Event
|
||||
{
|
||||
/**
|
||||
* The newly created graphics object.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where the {@link GroundObject} on a {@link Tile} has been changed.
|
||||
*/
|
||||
@Data
|
||||
public class GroundObjectChanged
|
||||
public class GroundObjectChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link GroundObject} on a {@link Tile} has been removed.
|
||||
*/
|
||||
@Data
|
||||
public class GroundObjectDespawned
|
||||
public class GroundObjectDespawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link GroundObject} is added to a {@link Tile}.
|
||||
*/
|
||||
@Data
|
||||
public class GroundObjectSpawned
|
||||
public class GroundObjectSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -36,7 +36,7 @@ import lombok.Data;
|
||||
* visible hitsplats.
|
||||
*/
|
||||
@Data
|
||||
public class HitsplatApplied
|
||||
public class HitsplatApplied implements Event
|
||||
{
|
||||
/**
|
||||
* The actor the hitsplat was applied to.
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.runelite.api.Actor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class InteractChanged
|
||||
public class InteractChanged implements Event
|
||||
{
|
||||
private Actor actor;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Value;
|
||||
* An event called when the actor an actor is interacting with changes
|
||||
*/
|
||||
@Value
|
||||
public class InteractingChanged
|
||||
public class InteractingChanged implements Event
|
||||
{
|
||||
private final Actor source;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import lombok.Value;
|
||||
* </ul>
|
||||
*/
|
||||
@Value
|
||||
public class ItemContainerChanged
|
||||
public class ItemContainerChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The modified container's ID.
|
||||
|
||||
@@ -34,7 +34,7 @@ import lombok.Value;
|
||||
* all item piles are implicitly despawned, and despawn events will not be sent.
|
||||
*/
|
||||
@Value
|
||||
public class ItemDespawned
|
||||
public class ItemDespawned implements Event
|
||||
{
|
||||
private final Tile tile;
|
||||
private final TileItem item;
|
||||
|
||||
@@ -33,7 +33,7 @@ import lombok.Value;
|
||||
* Called when the quantity of an item pile changes.
|
||||
*/
|
||||
@Value
|
||||
public class ItemQuantityChanged
|
||||
public class ItemQuantityChanged implements Event
|
||||
{
|
||||
private final TileItem item;
|
||||
private final Tile tile;
|
||||
|
||||
@@ -34,7 +34,7 @@ import lombok.Value;
|
||||
* all item piles are implicitly reset and a new spawn event will be sent.
|
||||
*/
|
||||
@Value
|
||||
public class ItemSpawned
|
||||
public class ItemSpawned implements Event
|
||||
{
|
||||
private final Tile tile;
|
||||
private final TileItem item;
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
/**
|
||||
* An event when the local player dies.
|
||||
*/
|
||||
public class LocalPlayerDeath
|
||||
public class LocalPlayerDeath implements Event
|
||||
{
|
||||
public static final LocalPlayerDeath INSTANCE = new LocalPlayerDeath();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.runelite.api.MenuEntry;
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MenuEntryAdded
|
||||
public class MenuEntryAdded implements Event
|
||||
{
|
||||
/**
|
||||
* The MenuEntry object that was actually added
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* An event where a menu has been opened.
|
||||
*/
|
||||
@Data
|
||||
public class MenuOpened
|
||||
public class MenuOpened implements Event
|
||||
{
|
||||
/**
|
||||
* The menu entries in the newly opened menu.
|
||||
|
||||
@@ -42,7 +42,7 @@ import net.runelite.api.MenuEntry;
|
||||
* it seems that this event still triggers with the "Cancel" action.
|
||||
*/
|
||||
@Data
|
||||
public class MenuOptionClicked
|
||||
public class MenuOptionClicked implements Event
|
||||
{
|
||||
public MenuOptionClicked(MenuEntry entry)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* opened on left click.
|
||||
*/
|
||||
@Data
|
||||
public class MenuShouldLeftClick
|
||||
public class MenuShouldLeftClick implements Event
|
||||
{
|
||||
/**
|
||||
* If set to true, the menu will open on left click.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Value;
|
||||
* An event where a {@link Nameable} has had their name changed.
|
||||
*/
|
||||
@Value
|
||||
public class NameableNameChanged
|
||||
public class NameableNameChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The nameable that changed names.
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.runelite.api.NPCDefinition;
|
||||
* An event where an action of an {@link NPCDefinition} has changed.
|
||||
*/
|
||||
@Data
|
||||
public class NpcActionChanged
|
||||
public class NpcActionChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The NPC composition that has been changed.
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.runelite.api.NPC;
|
||||
* Fires after the composition of an {@link NPC} changes.
|
||||
*/
|
||||
@Value
|
||||
public class NpcDefinitionChanged
|
||||
public class NpcDefinitionChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The NPC of which the composition changed.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Value;
|
||||
* An event where an {@link NPC} has despawned.
|
||||
*/
|
||||
@Value
|
||||
public class NpcDespawned
|
||||
public class NpcDespawned implements Event
|
||||
{
|
||||
/**
|
||||
* The despawned NPC.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Value;
|
||||
* An event where an {@link NPC} has spawned.
|
||||
*/
|
||||
@Value
|
||||
public class NpcSpawned
|
||||
public class NpcSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The spawned NPC.
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.runelite.api.Actor;
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class OverheadTextChanged
|
||||
public class OverheadTextChanged implements Event
|
||||
{
|
||||
private final Actor actor;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import lombok.Value;
|
||||
* Note: This event does not get called for the local player.
|
||||
*/
|
||||
@Value
|
||||
public class PlayerDespawned
|
||||
public class PlayerDespawned implements Event
|
||||
{
|
||||
/**
|
||||
* The despawned player.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* been clicked (ie. HiScore Lookup).
|
||||
*/
|
||||
@Data
|
||||
public class PlayerMenuOptionClicked
|
||||
public class PlayerMenuOptionClicked implements Event
|
||||
{
|
||||
/**
|
||||
* The menu option clicked.
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlayerMenuOptionsChanged
|
||||
public class PlayerMenuOptionsChanged implements Event
|
||||
{
|
||||
/**
|
||||
* Index in playerOptions which changed.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Value;
|
||||
* An event where a {@link Player} has spawned.
|
||||
*/
|
||||
@Value
|
||||
public class PlayerSpawned
|
||||
public class PlayerSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The spawned player.
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.runelite.api.HealthBar;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PostHealthBar
|
||||
public class PostHealthBar implements Event
|
||||
{
|
||||
private HealthBar healthBar;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.runelite.api.ItemDefinition;
|
||||
* its data is initialized.
|
||||
*/
|
||||
@Data
|
||||
public class PostItemDefinition
|
||||
public class PostItemDefinition implements Event
|
||||
{
|
||||
/**
|
||||
* The newly created item.
|
||||
|
||||
@@ -35,7 +35,7 @@ import lombok.Data;
|
||||
* once (ie. AoE from Lizardman Shaman).
|
||||
*/
|
||||
@Data
|
||||
public class ProjectileMoved
|
||||
public class ProjectileMoved implements Event
|
||||
{
|
||||
/**
|
||||
* The projectile being moved.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event called whenever a {@link Projectile} has spawned.
|
||||
*/
|
||||
@Data
|
||||
public class ProjectileSpawned
|
||||
public class ProjectileSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The spawned projectile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where the game has changed from fixed to resizable mode or vice versa.
|
||||
*/
|
||||
@Data
|
||||
public class ResizeableChanged
|
||||
public class ResizeableChanged implements Event
|
||||
{
|
||||
/**
|
||||
* Whether the game is in resizable mode.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* A callback from a runelite_callback opcode in a cs2
|
||||
*/
|
||||
@Data
|
||||
public class ScriptCallbackEvent
|
||||
public class ScriptCallbackEvent implements Event
|
||||
{
|
||||
/**
|
||||
* The script being called.
|
||||
|
||||
@@ -27,7 +27,7 @@ package net.runelite.api.events;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SoundEffectPlayed
|
||||
public class SoundEffectPlayed implements Event
|
||||
{
|
||||
private int soundId;
|
||||
private int delay;
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.runelite.api.Actor;
|
||||
* @see net.runelite.api.GraphicID
|
||||
*/
|
||||
@Data
|
||||
public class SpotAnimationChanged
|
||||
public class SpotAnimationChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The actor that has had their graphic changed.
|
||||
|
||||
@@ -30,7 +30,7 @@ package net.runelite.api.events;
|
||||
* This event triggers for every character change to the username
|
||||
* in the login screen.
|
||||
*/
|
||||
public class UsernameChanged
|
||||
public class UsernameChanged implements Event
|
||||
{
|
||||
public static final UsernameChanged INSTANCE = new UsernameChanged();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Value;
|
||||
* An event where a varbit integer has changed.
|
||||
*/
|
||||
@Value
|
||||
public class VarClientIntChanged
|
||||
public class VarClientIntChanged implements Event
|
||||
{
|
||||
private int index;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Value;
|
||||
* An event where a varbit string has changed.
|
||||
*/
|
||||
@Value
|
||||
public class VarClientStrChanged
|
||||
public class VarClientStrChanged implements Event
|
||||
{
|
||||
private int index;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event when a varbit or varplayer has changed.
|
||||
*/
|
||||
@Data
|
||||
public class VarbitChanged
|
||||
public class VarbitChanged implements Event
|
||||
{
|
||||
/**
|
||||
* Index in the varp array that was changed.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where the {@link WallObject} of a {@link Tile} has been changed.
|
||||
*/
|
||||
@Data
|
||||
public class WallObjectChanged
|
||||
public class WallObjectChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link WallObject} on a {@link Tile} has been removed.
|
||||
*/
|
||||
@Data
|
||||
public class WallObjectDespawned
|
||||
public class WallObjectDespawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.Data;
|
||||
* An event where a {@link WallObject} is added to a {@link Tile}.
|
||||
*/
|
||||
@Data
|
||||
public class WallObjectSpawned
|
||||
public class WallObjectSpawned implements Event
|
||||
{
|
||||
/**
|
||||
* The affected tile.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* An event where the hidden state of a {@link Widget} has been modified.
|
||||
*/
|
||||
@Data
|
||||
public class WidgetHiddenChanged
|
||||
public class WidgetHiddenChanged implements Event
|
||||
{
|
||||
/**
|
||||
* The affected widget.
|
||||
|
||||
@@ -30,7 +30,7 @@ import lombok.Data;
|
||||
* An event where a {@link net.runelite.api.widgets.Widget} has been loaded.
|
||||
*/
|
||||
@Data
|
||||
public class WidgetLoaded
|
||||
public class WidgetLoaded implements Event
|
||||
{
|
||||
/**
|
||||
* The group ID of the loaded widget.
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* An event where an option has been clicked in a {@link net.runelite.api.widgets.Widget}s menu.
|
||||
*/
|
||||
@Data
|
||||
public class WidgetMenuOptionClicked
|
||||
public class WidgetMenuOptionClicked implements Event
|
||||
{
|
||||
/**
|
||||
* The clicked menu option.
|
||||
|
||||
@@ -28,7 +28,7 @@ package net.runelite.api.events;
|
||||
* An event where the position of a {@link net.runelite.api.widgets.Widget}
|
||||
* relative to its parent has changed.
|
||||
*/
|
||||
public class WidgetPositioned
|
||||
public class WidgetPositioned implements Event
|
||||
{
|
||||
public static final WidgetPositioned INSTANCE = new WidgetPositioned();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Data;
|
||||
* An event where a draggable widget has been pressed.
|
||||
*/
|
||||
@Data
|
||||
public class WidgetPressed
|
||||
public class WidgetPressed implements Event
|
||||
{
|
||||
public static final WidgetPressed INSTANCE = new WidgetPressed();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import lombok.Value;
|
||||
* Event when the world list is loaded for the world switcher
|
||||
*/
|
||||
@Value
|
||||
public class WorldListLoad
|
||||
public class WorldListLoad implements Event
|
||||
{
|
||||
private final World[] worlds;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package net.runelite.api.hooks;
|
||||
|
||||
import net.runelite.api.MainBufferProvider;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -41,14 +42,14 @@ public interface Callbacks
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
<T> void post(Class<T> eventClass, Object event);
|
||||
<T> void post(Class<T> eventClass, Event event);
|
||||
|
||||
/**
|
||||
* Post a deferred event, which gets delayed until the next cycle.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
<T> void postDeferred(Class<T> eventClass, Object event);
|
||||
<T> void postDeferred(Class<T> eventClass, Event event);
|
||||
|
||||
/**
|
||||
* Called each client cycle.
|
||||
|
||||
@@ -50,6 +50,7 @@ import net.runelite.api.Renderable;
|
||||
import net.runelite.api.WorldMapManager;
|
||||
import net.runelite.api.events.BeforeMenuRender;
|
||||
import net.runelite.api.events.BeforeRender;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.hooks.Callbacks;
|
||||
import net.runelite.api.hooks.DrawCallbacks;
|
||||
@@ -128,13 +129,13 @@ public class Hooks implements Callbacks
|
||||
private boolean shouldProcessGameTick;
|
||||
|
||||
@Override
|
||||
public <T> void post(Class<T> eventClass, Object event)
|
||||
public <T> void post(Class<T> eventClass, Event event)
|
||||
{
|
||||
eventBus.post(eventClass, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void postDeferred(Class<T> eventClass, Object event)
|
||||
public <T> void postDeferred(Class<T> eventClass, Event event)
|
||||
{
|
||||
deferredEventBus.post(eventClass, event);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
package net.runelite.client.discord.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
/**
|
||||
* Called when the RPC connection has been severed
|
||||
*/
|
||||
@Value
|
||||
public class DiscordDisconnected
|
||||
public class DiscordDisconnected implements Event
|
||||
{
|
||||
/**
|
||||
* Discord error code
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
package net.runelite.client.discord.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
/**
|
||||
* Called when an internal error is caught within the SDK
|
||||
*/
|
||||
@Value
|
||||
public class DiscordErrored
|
||||
public class DiscordErrored implements Event
|
||||
{
|
||||
/**
|
||||
* Discord error code.
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
package net.runelite.client.discord.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
/**
|
||||
* Called when the logged in user joined a game
|
||||
*/
|
||||
@Value
|
||||
public class DiscordJoinGame
|
||||
public class DiscordJoinGame implements Event
|
||||
{
|
||||
/**
|
||||
* Obfuscated data of your choosing used as join secret
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
package net.runelite.client.discord.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
/**
|
||||
* Called when another discord user wants to join the game of the logged in user
|
||||
*/
|
||||
@Value
|
||||
public class DiscordJoinRequest
|
||||
public class DiscordJoinRequest implements Event
|
||||
{
|
||||
/**
|
||||
* The userId for the user that requests to join
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
package net.runelite.client.discord.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
/**
|
||||
* Called when the RPC connection has been established
|
||||
*/
|
||||
@Value
|
||||
public class DiscordReady
|
||||
public class DiscordReady implements Event
|
||||
{
|
||||
/**
|
||||
* The userId for the active user
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
package net.runelite.client.discord.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
/**
|
||||
* Called when the logged in user joined to spectate a game
|
||||
*/
|
||||
@Value
|
||||
public class DiscordSpectateGame
|
||||
public class DiscordSpectateGame implements Event
|
||||
{
|
||||
/**
|
||||
* Obfuscated data of your choosing used as spectate secret
|
||||
|
||||
@@ -11,12 +11,14 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.Event;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class EventBus implements EventBusInterface
|
||||
{
|
||||
private Map<Object, Object> subscriptionList = new HashMap<>();
|
||||
private Map<Class<?>, Relay<Object>> subjectList = new HashMap<>();
|
||||
private Map<Object, CompositeDisposable> subscriptionsMap = new HashMap<>();
|
||||
|
||||
@@ -43,6 +45,11 @@ public class EventBus implements EventBusInterface
|
||||
// Subscribe on lifecycle (for example from plugin startUp -> shutdown)
|
||||
public <T> void subscribe(Class<T> eventClass, @NonNull Object lifecycle, @NonNull Consumer<T> action)
|
||||
{
|
||||
if (subscriptionList.containsKey(lifecycle) && eventClass.equals(subscriptionList.get(lifecycle)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Disposable disposable = getSubject(eventClass)
|
||||
.filter(Objects::nonNull) // Filter out null objects, better safe than sorry
|
||||
.cast(eventClass) // Cast it for easier usage
|
||||
@@ -53,6 +60,7 @@ public class EventBus implements EventBusInterface
|
||||
});
|
||||
|
||||
getCompositeDisposable(lifecycle).add(disposable);
|
||||
subscriptionList.put(lifecycle, eventClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,6 +68,7 @@ public class EventBus implements EventBusInterface
|
||||
{
|
||||
//We have to remove the composition from the map, because once you dispose it can't be used anymore
|
||||
CompositeDisposable compositeDisposable = subscriptionsMap.remove(lifecycle);
|
||||
subscriptionList.remove(lifecycle);
|
||||
if (compositeDisposable != null)
|
||||
{
|
||||
compositeDisposable.dispose();
|
||||
@@ -67,7 +76,7 @@ public class EventBus implements EventBusInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void post(Class<T> eventClass, @NonNull Object event)
|
||||
public <T> void post(Class<T> eventClass, @NonNull Event event)
|
||||
{
|
||||
getSubject(eventClass).accept(event);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.runelite.client.eventbus;
|
||||
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import net.runelite.api.events.Event;
|
||||
|
||||
public interface EventBusInterface
|
||||
{
|
||||
@@ -9,5 +10,5 @@ public interface EventBusInterface
|
||||
|
||||
void unregister(@NonNull Object lifecycle);
|
||||
|
||||
<T> void post(Class<T> eventClass, @NonNull Object event);
|
||||
<T> void post(Class<T> eventClass, @NonNull Event event);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
package net.runelite.client.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@Value
|
||||
public class NavigationButtonAdded
|
||||
public class NavigationButtonAdded implements Event
|
||||
{
|
||||
private NavigationButton button;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
package net.runelite.client.events;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@Value
|
||||
public class NavigationButtonRemoved
|
||||
public class NavigationButtonRemoved implements Event
|
||||
{
|
||||
private NavigationButton button;
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@ package net.runelite.client.events;
|
||||
import java.util.Collection;
|
||||
import lombok.Value;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.events.Event;
|
||||
import net.runelite.client.game.ItemStack;
|
||||
|
||||
@Value
|
||||
public class NpcLootReceived
|
||||
public class NpcLootReceived implements Event
|
||||
{
|
||||
private final NPC npc;
|
||||
private final Collection<ItemStack> items;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user