Convert game thread events to singletons (#794)

* Convert game thread events to singletons

* Fix checkstyle

* Fix copy paste error
This commit is contained in:
Owain van Brakel
2019-06-28 22:11:57 +02:00
committed by James
parent 23f6463024
commit 38d9800d10
102 changed files with 756 additions and 220 deletions

View File

@@ -20,6 +20,13 @@ import net.runelite.api.Actor;
@Data @Data
public class AnimationChanged public class AnimationChanged
{ {
public static final AnimationChanged INSTANCE = new AnimationChanged();
private AnimationChanged()
{
// noop
}
/** /**
* The actor that has entered a new animation. * The actor that has entered a new animation.
*/ */

View File

@@ -29,6 +29,13 @@ import lombok.Data;
@Data @Data
public class AreaSoundEffectPlayed public class AreaSoundEffectPlayed
{ {
public static final AreaSoundEffectPlayed INSTANCE = new AreaSoundEffectPlayed();
private AreaSoundEffectPlayed()
{
// noop
}
private int soundId; private int soundId;
private int sceneX; private int sceneX;
private int sceneY; private int sceneY;

View File

@@ -29,6 +29,13 @@ import lombok.Data;
@Data @Data
public class BeforeMenuRender public class BeforeMenuRender
{ {
public static final BeforeMenuRender INSTANCE = new BeforeMenuRender();
private BeforeMenuRender()
{
// noop
}
private boolean consumed; private boolean consumed;
public void consume() public void consume()

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/ */
public class BeforeRender public class BeforeRender
{ {
public static final BeforeRender INSTANCE = new BeforeRender();
private BeforeRender()
{
// noop
}
} }

View File

@@ -44,6 +44,13 @@ import lombok.Data;
@Data @Data
public class BoostedLevelChanged public class BoostedLevelChanged
{ {
public static final BoostedLevelChanged INSTANCE = new BoostedLevelChanged();
private BoostedLevelChanged()
{
// noop
}
/** /**
* The skill that has had its level modified. * The skill that has had its level modified.
*/ */

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/ */
public class CannonballFired public class CannonballFired
{ {
public static final CannonballFired INSTANCE = new CannonballFired();
private CannonballFired()
{
// noop
}
} }

View File

@@ -28,7 +28,6 @@ import net.runelite.api.ChatMessageType;
import net.runelite.api.MessageNode; import net.runelite.api.MessageNode;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* An event where a new chat message is received. * An event where a new chat message is received.
@@ -40,9 +39,15 @@ import lombok.NoArgsConstructor;
*/ */
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
public class ChatMessage public class ChatMessage
{ {
public static final ChatMessage INSTANCE = new ChatMessage();
private ChatMessage()
{
// noop
}
/** /**
* The underlying MessageNode for the message. * The underlying MessageNode for the message.
*/ */

View File

@@ -24,14 +24,21 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Data;
/** /**
* An event where the client has joined or left a clan chat. * An event where the client has joined or left a clan chat.
*/ */
@Value @Data
public class ClanChanged public class ClanChanged
{ {
public static final ClanChanged INSTANCE = new ClanChanged();
private ClanChanged()
{
// noop
}
/** /**
* Whether or not the client is now in a clan chat. * Whether or not the client is now in a clan chat.
*/ */

View File

@@ -25,11 +25,18 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.ClanMember; import net.runelite.api.ClanMember;
import lombok.Value; import lombok.Data;
@Value @Data
public class ClanMemberJoined public class ClanMemberJoined
{ {
public static final ClanMemberJoined INSTANCE = new ClanMemberJoined();
private ClanMemberJoined()
{
// noop
}
/** /**
* The ClanMember that joined * The ClanMember that joined
*/ */

View File

@@ -25,11 +25,18 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.ClanMember; import net.runelite.api.ClanMember;
import lombok.Value; import lombok.Data;
@Value @Data
public class ClanMemberLeft public class ClanMemberLeft
{ {
public static final ClanMemberLeft INSTANCE = new ClanMemberLeft();
private ClanMemberLeft()
{
// noop
}
/** /**
* The ClanMember that left * The ClanMember that left
*/ */

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/ */
public class ClientTick public class ClientTick
{ {
public static final ClientTick INSTANCE = new ClientTick();
private ClientTick()
{
// noop
}
} }

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Data;
/** /**
* An event where a command has been used in the chat. * An event where a command has been used in the chat.
@@ -41,9 +41,16 @@ import lombok.Value;
* set the command field to an empty string. For example, the message ":: hello world!" * set the command field to an empty string. For example, the message ":: hello world!"
* will set command to "" and arguments to ["hello", "world!"]. * will set command to "" and arguments to ["hello", "world!"].
*/ */
@Value @Data
public class CommandExecuted public class CommandExecuted
{ {
public static final CommandExecuted INSTANCE = new CommandExecuted();
private CommandExecuted()
{
// noop
}
/** /**
* The name of the command entered. * The name of the command entered.
*/ */

View File

@@ -35,6 +35,13 @@ import lombok.Data;
@Data @Data
public class DecorativeObjectChanged public class DecorativeObjectChanged
{ {
public static final DecorativeObjectChanged INSTANCE = new DecorativeObjectChanged();
private DecorativeObjectChanged()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -35,6 +35,13 @@ import lombok.Data;
@Data @Data
public class DecorativeObjectDespawned public class DecorativeObjectDespawned
{ {
public static final DecorativeObjectDespawned INSTANCE = new DecorativeObjectDespawned();
private DecorativeObjectDespawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class DecorativeObjectSpawned public class DecorativeObjectSpawned
{ {
public static final DecorativeObjectSpawned INSTANCE = new DecorativeObjectSpawned();
private DecorativeObjectSpawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class DraggingWidgetChanged public class DraggingWidgetChanged
{ {
public static final DraggingWidgetChanged INSTANCE = new DraggingWidgetChanged();
private DraggingWidgetChanged()
{
// noop
}
/** /**
* Whether a widget is currently being dragged. * Whether a widget is currently being dragged.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class ExperienceChanged public class ExperienceChanged
{ {
public static final ExperienceChanged INSTANCE = new ExperienceChanged();
private ExperienceChanged()
{
// noop
}
/** /**
* The modified skill. * The modified skill.
*/ */

View File

@@ -34,6 +34,13 @@ import net.runelite.api.Tile;
@Data @Data
public class GameObjectChanged public class GameObjectChanged
{ {
public static final GameObjectChanged INSTANCE = new GameObjectChanged();
private GameObjectChanged()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class GameObjectDespawned public class GameObjectDespawned
{ {
public static final GameObjectDespawned INSTANCE = new GameObjectDespawned();
private GameObjectDespawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class GameObjectSpawned public class GameObjectSpawned
{ {
public static final GameObjectSpawned INSTANCE = new GameObjectSpawned();
private GameObjectSpawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class GameStateChanged public class GameStateChanged
{ {
public static final GameStateChanged INSTANCE = new GameStateChanged();
private GameStateChanged()
{
// noop
}
/** /**
* The new game state. * The new game state.
*/ */

View File

@@ -24,8 +24,6 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
// The NPC update event seem to run every server tick, // The NPC update event seem to run every server tick,
// but having the game tick event after all packets // but having the game tick event after all packets
// have been processed is typically more useful. // have been processed is typically more useful.
@@ -43,7 +41,12 @@ import lombok.Data;
* Note that occurrences that take place purely on the client, such as right * Note that occurrences that take place purely on the client, such as right
* click menus, are independent of the game tick. * click menus, are independent of the game tick.
*/ */
@Data
public class GameTick public class GameTick
{ {
public static final GameTick INSTANCE = new GameTick();
private GameTick()
{
// noop
}
} }

View File

@@ -44,6 +44,13 @@ import lombok.Data;
@Data @Data
public class GrandExchangeOfferChanged public class GrandExchangeOfferChanged
{ {
public static final GrandExchangeOfferChanged INSTANCE = new GrandExchangeOfferChanged();
private GrandExchangeOfferChanged()
{
// noop
}
/** /**
* The offer that has been modified. * The offer that has been modified.
*/ */

View File

@@ -25,16 +25,24 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.GraphicsObject; import net.runelite.api.GraphicsObject;
import lombok.Value;
import lombok.Data;
/** /**
* An event where a new {@link GraphicsObject} has been created. * An event where a new {@link GraphicsObject} has been created.
*/ */
@Value @Data
public class GraphicsObjectCreated public class GraphicsObjectCreated
{ {
public static final GraphicsObjectCreated INSTANCE = new GraphicsObjectCreated();
private GraphicsObjectCreated()
{
// noop
}
/** /**
* The newly created graphics object. * The newly created graphics object.
*/ */
private final GraphicsObject graphicsObject; private GraphicsObject graphicsObject;
} }

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class GroundObjectChanged public class GroundObjectChanged
{ {
public static final GroundObjectChanged INSTANCE = new GroundObjectChanged();
private GroundObjectChanged()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class GroundObjectDespawned public class GroundObjectDespawned
{ {
public static final GroundObjectDespawned INSTANCE = new GroundObjectDespawned();
private GroundObjectDespawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class GroundObjectSpawned public class GroundObjectSpawned
{ {
public static final GroundObjectSpawned INSTANCE = new GroundObjectSpawned();
private GroundObjectSpawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -38,6 +38,13 @@ import lombok.Data;
@Data @Data
public class HitsplatApplied public class HitsplatApplied
{ {
public static final HitsplatApplied INSTANCE = new HitsplatApplied();
private HitsplatApplied()
{
// noop
}
/** /**
* The actor the hitsplat was applied to. * The actor the hitsplat was applied to.
*/ */

View File

@@ -30,5 +30,12 @@ import lombok.Data;
@Data @Data
public class InteractChanged public class InteractChanged
{ {
public static final InteractChanged INSTANCE = new InteractChanged();
private InteractChanged()
{
// noop
}
private Actor actor; private Actor actor;
} }

View File

@@ -1,18 +1,26 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import lombok.Value;
import lombok.Data;
/** /**
* An event called when the actor an actor is interacting with changes * An event called when the actor an actor is interacting with changes
*/ */
@Value @Data
public class InteractingChanged public class InteractingChanged
{ {
private final Actor source; public static final InteractingChanged INSTANCE = new InteractingChanged();
private InteractingChanged()
{
// noop
}
private Actor source;
/** /**
* Target actor, may be null * Target actor, may be null
*/ */
private final Actor target; private Actor target;
} }

View File

@@ -25,7 +25,8 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import lombok.Value;
import lombok.Data;
/** /**
* An event called whenever the stack size of an {@link api.Item} * An event called whenever the stack size of an {@link api.Item}
@@ -38,11 +39,18 @@ import lombok.Value;
* <li>Dropping an item</li> * <li>Dropping an item</li>
* </ul> * </ul>
*/ */
@Value @Data
public class ItemContainerChanged public class ItemContainerChanged
{ {
public static final ItemContainerChanged INSTANCE = new ItemContainerChanged();
private ItemContainerChanged()
{
// noop
}
/** /**
* The modified item container. * The modified item container.
*/ */
private final ItemContainer itemContainer; private ItemContainer itemContainer;
} }

View File

@@ -26,15 +26,23 @@ package net.runelite.api.events;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Value;
import lombok.Data;
/** /**
* Called when an item pile despawns from the ground. When the client loads a new scene, * Called when an item pile despawns from the ground. When the client loads a new scene,
* all item piles are implicitly despawned, and despawn events will not be sent. * all item piles are implicitly despawned, and despawn events will not be sent.
*/ */
@Value @Data
public class ItemDespawned public class ItemDespawned
{ {
private final Tile tile; public static final ItemDespawned INSTANCE = new ItemDespawned();
private final Item item;
private ItemDespawned()
{
// noop
}
private Tile tile;
private Item item;
} }

View File

@@ -26,16 +26,23 @@ package net.runelite.api.events;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Value; import lombok.Data;
/** /**
* Called when the quantity of an item pile changes. * Called when the quantity of an item pile changes.
*/ */
@Value @Data
public class ItemQuantityChanged public class ItemQuantityChanged
{ {
private final Item item; public static final ItemQuantityChanged INSTANCE = new ItemQuantityChanged();
private final Tile tile;
private final int oldQuantity; private ItemQuantityChanged()
private final int newQuantity; {
// noop
}
private Item item;
private Tile tile;
private int oldQuantity;
private int newQuantity;
} }

View File

@@ -26,15 +26,22 @@ package net.runelite.api.events;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Value; import lombok.Data;
/** /**
* Called when an item pile spawns on the ground. When the client loads a new scene, * Called when an item pile spawns on the ground. When the client loads a new scene,
* all item piles are implicitly reset and a new spawn event will be sent. * all item piles are implicitly reset and a new spawn event will be sent.
*/ */
@Value @Data
public class ItemSpawned public class ItemSpawned
{ {
private final Tile tile; public static final ItemSpawned INSTANCE = new ItemSpawned();
private final Item item;
private ItemSpawned()
{
// noop
}
private Tile tile;
private Item item;
} }

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/ */
public class LocalPlayerDeath public class LocalPlayerDeath
{ {
public static final LocalPlayerDeath INSTANCE = new LocalPlayerDeath();
private LocalPlayerDeath()
{
// noop
}
} }

View File

@@ -35,10 +35,17 @@ import net.runelite.api.MenuEntry;
@AllArgsConstructor @AllArgsConstructor
public class MenuEntryAdded public class MenuEntryAdded
{ {
public static final MenuEntryAdded INSTANCE = new MenuEntryAdded();
private MenuEntryAdded()
{
// noop
}
/** /**
* The MenuEntry object that was actually added * The MenuEntry object that was actually added
*/ */
private final MenuEntry menuEntry; private MenuEntry menuEntry;
public String getOption() public String getOption()
{ {

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class MenuOpened public class MenuOpened
{ {
public static final MenuOpened INSTANCE = new MenuOpened();
private MenuOpened()
{
// noop
}
/** /**
* The menu entries in the newly opened menu. * The menu entries in the newly opened menu.
* <p> * <p>

View File

@@ -42,6 +42,13 @@ import net.runelite.api.MenuEntry;
@Data @Data
public class MenuOptionClicked public class MenuOptionClicked
{ {
public static final MenuOptionClicked INSTANCE = new MenuOptionClicked();
private MenuOptionClicked()
{
// noop
}
public MenuOptionClicked(MenuEntry entry) public MenuOptionClicked(MenuEntry entry)
{ {
menuEntry = entry; menuEntry = entry;

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class MenuShouldLeftClick public class MenuShouldLeftClick
{ {
public static final MenuShouldLeftClick INSTANCE = new MenuShouldLeftClick();
private MenuShouldLeftClick()
{
// noop
}
/** /**
* If set to true, the menu will open on left click. * If set to true, the menu will open on left click.
*/ */

View File

@@ -25,16 +25,23 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.Nameable; import net.runelite.api.Nameable;
import lombok.Value; import lombok.Data;
/** /**
* An event where a {@link Nameable} has had their name changed. * An event where a {@link Nameable} has had their name changed.
*/ */
@Value @Data
public class NameableNameChanged public class NameableNameChanged
{ {
public static final NameableNameChanged INSTANCE = new NameableNameChanged();
private NameableNameChanged()
{
// noop
}
/** /**
* The nameable that changed names. * The nameable that changed names.
*/ */
private final Nameable nameable; private Nameable nameable;
} }

View File

@@ -33,6 +33,13 @@ import net.runelite.api.NPCDefinition;
@Data @Data
public class NpcActionChanged public class NpcActionChanged
{ {
public static final NpcActionChanged INSTANCE = new NpcActionChanged();
private NpcActionChanged()
{
// noop
}
/** /**
* The NPC composition that has been changed. * The NPC composition that has been changed.
*/ */

View File

@@ -26,18 +26,25 @@ package net.runelite.api.events;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import lombok.Value; import lombok.Data;
/** /**
* An event where an {@link NPC} has despawned. * An event where an {@link NPC} has despawned.
*/ */
@Value @Data
public class NpcDespawned public class NpcDespawned
{ {
public static final NpcDespawned INSTANCE = new NpcDespawned();
private NpcDespawned()
{
// noop
}
/** /**
* The despawned NPC. * The despawned NPC.
*/ */
private final NPC npc; private NPC npc;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -26,18 +26,25 @@ package net.runelite.api.events;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import lombok.Value; import lombok.Data;
/** /**
* An event where an {@link NPC} has spawned. * An event where an {@link NPC} has spawned.
*/ */
@Value @Data
public class NpcSpawned public class NpcSpawned
{ {
public static final NpcSpawned INSTANCE = new NpcSpawned();
private NpcSpawned()
{
// noop
}
/** /**
* The spawned NPC. * The spawned NPC.
*/ */
private final NPC npc; private NPC npc;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -1,12 +1,19 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import lombok.Value; import lombok.Data;
@Value @Data
public class OverheadTextChanged public class OverheadTextChanged
{ {
private final Actor actor; public static final OverheadTextChanged INSTANCE = new OverheadTextChanged();
private final String overheadText; private OverheadTextChanged()
{
// noop
}
private Actor actor;
private String overheadText;
} }

View File

@@ -26,20 +26,27 @@ package net.runelite.api.events;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Player; import net.runelite.api.Player;
import lombok.Value; import lombok.Data;
/** /**
* An event where a {@link Player} has despawned. * An event where a {@link Player} has despawned.
* <p> * <p>
* Note: This event does not get called for the local player. * Note: This event does not get called for the local player.
*/ */
@Value @Data
public class PlayerDespawned public class PlayerDespawned
{ {
public static final PlayerDespawned INSTANCE = new PlayerDespawned();
private PlayerDespawned()
{
// noop
}
/** /**
* The despawned player. * The despawned player.
*/ */
private final Player player; private Player player;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class PlayerMenuOptionClicked public class PlayerMenuOptionClicked
{ {
public static final PlayerMenuOptionClicked INSTANCE = new PlayerMenuOptionClicked();
private PlayerMenuOptionClicked()
{
// noop
}
/** /**
* The menu option clicked. * The menu option clicked.
*/ */

View File

@@ -29,6 +29,13 @@ import lombok.Data;
@Data @Data
public class PlayerMenuOptionsChanged public class PlayerMenuOptionsChanged
{ {
public static final PlayerMenuOptionsChanged INSTANCE = new PlayerMenuOptionsChanged();
private PlayerMenuOptionsChanged()
{
// noop
}
/** /**
* Index in playerOptions which changed. * Index in playerOptions which changed.
*/ */

View File

@@ -26,18 +26,25 @@ package net.runelite.api.events;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Player; import net.runelite.api.Player;
import lombok.Value; import lombok.Data;
/** /**
* An event where a {@link Player} has spawned. * An event where a {@link Player} has spawned.
*/ */
@Value @Data
public class PlayerSpawned public class PlayerSpawned
{ {
public static final PlayerSpawned INSTANCE = new PlayerSpawned();
private PlayerSpawned()
{
// noop
}
/** /**
* The spawned player. * The spawned player.
*/ */
private final Player player; private Player player;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -30,5 +30,12 @@ import lombok.Data;
@Data @Data
public class PostHealthBar public class PostHealthBar
{ {
public static final PostHealthBar INSTANCE = new PostHealthBar();
private PostHealthBar()
{
// noop
}
private HealthBar healthBar; private HealthBar healthBar;
} }

View File

@@ -34,6 +34,13 @@ import net.runelite.api.ItemDefinition;
@Data @Data
public class PostItemDefinition public class PostItemDefinition
{ {
public static final PostItemDefinition INSTANCE = new PostItemDefinition();
private PostItemDefinition()
{
// noop
}
/** /**
* The newly created item. * The newly created item.
*/ */

View File

@@ -37,6 +37,13 @@ import lombok.Data;
@Data @Data
public class ProjectileMoved public class ProjectileMoved
{ {
public static final ProjectileMoved INSTANCE = new ProjectileMoved();
private ProjectileMoved()
{
// noop
}
/** /**
* The projectile being moved. * The projectile being moved.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class ProjectileSpawned public class ProjectileSpawned
{ {
public static final ProjectileSpawned INSTANCE = new ProjectileSpawned();
private ProjectileSpawned()
{
// noop
}
/** /**
* The spawned projectile. * The spawned projectile.
*/ */

View File

@@ -24,16 +24,23 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Data;
/** /**
* An event where a request to remove a friend is sent to the server. * An event where a request to remove a friend is sent to the server.
*/ */
@Value @Data
public class RemovedFriend public class RemovedFriend
{ {
public static final RemovedFriend INSTANCE = new RemovedFriend();
private RemovedFriend()
{
// noop
}
/** /**
* The name of the removed friend. * The name of the removed friend.
*/ */
private final String name; private String name;
} }

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class ResizeableChanged public class ResizeableChanged
{ {
public static final ResizeableChanged INSTANCE = new ResizeableChanged();
private ResizeableChanged()
{
// noop
}
/** /**
* Whether the game is in resizable mode. * Whether the game is in resizable mode.
*/ */

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class ScriptCallbackEvent public class ScriptCallbackEvent
{ {
public static final ScriptCallbackEvent INSTANCE = new ScriptCallbackEvent();
private ScriptCallbackEvent()
{
// noop
}
/** /**
* The script being called. * The script being called.
*/ */

View File

@@ -29,6 +29,13 @@ import lombok.Data;
@Data @Data
public class SoundEffectPlayed public class SoundEffectPlayed
{ {
public static final SoundEffectPlayed INSTANCE = new SoundEffectPlayed();
private SoundEffectPlayed()
{
// noop
}
private int soundId; private int soundId;
private int delay; private int delay;
} }

View File

@@ -21,6 +21,13 @@ import net.runelite.api.Actor;
@Data @Data
public class SpotAnimationChanged public class SpotAnimationChanged
{ {
public static final SpotAnimationChanged INSTANCE = new SpotAnimationChanged();
private SpotAnimationChanged()
{
// noop
}
/** /**
* The actor that has had their graphic changed. * The actor that has had their graphic changed.
*/ */

View File

@@ -32,4 +32,10 @@ package net.runelite.api.events;
*/ */
public class UsernameChanged public class UsernameChanged
{ {
public static final UsernameChanged INSTANCE = new UsernameChanged();
private UsernameChanged()
{
// noop
}
} }

View File

@@ -25,13 +25,20 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Data;
/** /**
* An event where a varbit integer has changed. * An event where a varbit integer has changed.
*/ */
@Value @Data
public class VarClientIntChanged public class VarClientIntChanged
{ {
public static final VarClientIntChanged INSTANCE = new VarClientIntChanged();
private VarClientIntChanged()
{
// noop
}
private int index; private int index;
} }

View File

@@ -25,13 +25,20 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Data;
/** /**
* An event where a varbit string has changed. * An event where a varbit string has changed.
*/ */
@Value @Data
public class VarClientStrChanged public class VarClientStrChanged
{ {
public static final VarClientStrChanged INSTANCE = new VarClientStrChanged();
private VarClientStrChanged()
{
// noop
}
private int index; private int index;
} }

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class VarbitChanged public class VarbitChanged
{ {
public static final VarbitChanged INSTANCE = new VarbitChanged();
private VarbitChanged()
{
// noop
}
/** /**
* Index in the varp array that was changed. * Index in the varp array that was changed.
* For varplayer, this is the varplayer id. * For varplayer, this is the varplayer id.

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class WallObjectChanged public class WallObjectChanged
{ {
public static final WallObjectChanged INSTANCE = new WallObjectChanged();
private WallObjectChanged()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class WallObjectDespawned public class WallObjectDespawned
{ {
public static final WallObjectDespawned INSTANCE = new WallObjectDespawned();
private WallObjectDespawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -34,6 +34,13 @@ import lombok.Data;
@Data @Data
public class WallObjectSpawned public class WallObjectSpawned
{ {
public static final WallObjectSpawned INSTANCE = new WallObjectSpawned();
private WallObjectSpawned()
{
// noop
}
/** /**
* The affected tile. * The affected tile.
*/ */

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class WidgetHiddenChanged public class WidgetHiddenChanged
{ {
public static final WidgetHiddenChanged INSTANCE = new WidgetHiddenChanged();
private WidgetHiddenChanged()
{
// noop
}
/** /**
* The affected widget. * The affected widget.
*/ */

View File

@@ -32,6 +32,13 @@ import lombok.Data;
@Data @Data
public class WidgetLoaded public class WidgetLoaded
{ {
public static final WidgetLoaded INSTANCE = new WidgetLoaded();
private WidgetLoaded()
{
// noop
}
/** /**
* The group ID of the loaded widget. * The group ID of the loaded widget.
*/ */

View File

@@ -33,6 +33,13 @@ import lombok.Data;
@Data @Data
public class WidgetMenuOptionClicked public class WidgetMenuOptionClicked
{ {
public static final WidgetMenuOptionClicked INSTANCE = new WidgetMenuOptionClicked();
private WidgetMenuOptionClicked()
{
// noop
}
/** /**
* The clicked menu option. * The clicked menu option.
*/ */

View File

@@ -24,13 +24,16 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value;
/** /**
* An event where the position of a {@link net.runelite.api.widgets.Widget} * An event where the position of a {@link net.runelite.api.widgets.Widget}
* relative to its parent has changed. * relative to its parent has changed.
*/ */
@Value
public class WidgetPositioned public class WidgetPositioned
{ {
public static final WidgetPositioned INSTANCE = new WidgetPositioned();
private WidgetPositioned()
{
// noop
}
} }

View File

@@ -25,13 +25,20 @@
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.World; import net.runelite.api.World;
import lombok.Value; import lombok.Data;
/** /**
* Event when the world list is loaded for the world switcher * Event when the world list is loaded for the world switcher
*/ */
@Value @Data
public class WorldListLoad public class WorldListLoad
{ {
private final World[] worlds; public static final WorldListLoad INSTANCE = new WorldListLoad();
private WorldListLoad()
{
// noop
}
private World[] worlds;
} }

View File

@@ -87,9 +87,6 @@ public class Hooks implements Callbacks
private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class); private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class);
private static final OverlayManager overlayManager = injector.getInstance(OverlayManager.class); private static final OverlayManager overlayManager = injector.getInstance(OverlayManager.class);
private static final GameTick GAME_TICK = new GameTick();
private static final BeforeRender BEFORE_RENDER = new BeforeRender();
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
@@ -151,13 +148,13 @@ public class Hooks implements Callbacks
deferredEventBus.replay(); deferredEventBus.replay();
eventBus.post(GAME_TICK); eventBus.post(GameTick.INSTANCE);
int tick = client.getTickCount(); int tick = client.getTickCount();
client.setTickCount(tick + 1); client.setTickCount(tick + 1);
} }
eventBus.post(BEFORE_RENDER); eventBus.post(BeforeRender.INSTANCE);
clientThread.invoke(); clientThread.invoke();
@@ -511,7 +508,7 @@ public class Hooks implements Callbacks
public static boolean drawMenu() public static boolean drawMenu()
{ {
BeforeMenuRender event = new BeforeMenuRender(); BeforeMenuRender event = BeforeMenuRender.INSTANCE;
client.getCallbacks().post(event); client.getCallbacks().post(event);
return event.isConsumed(); return event.isConsumed();
} }

View File

@@ -114,7 +114,9 @@ public class CommandManager
String command = split[0]; String command = split[0];
String[] args = Arrays.copyOfRange(split, 1, split.length); String[] args = Arrays.copyOfRange(split, 1, split.length);
CommandExecuted commandExecuted = new CommandExecuted(command, args); CommandExecuted commandExecuted = CommandExecuted.INSTANCE;
commandExecuted.setCommand(command);
commandExecuted.setArguments(args);
eventBus.post(commandExecuted); eventBus.post(commandExecuted);
} }

View File

@@ -429,7 +429,7 @@ public class MenuManager
if (curMenuOption.getMenuTarget().equals(event.getTarget()) if (curMenuOption.getMenuTarget().equals(event.getTarget())
&& curMenuOption.getMenuOption().equals(event.getOption())) && curMenuOption.getMenuOption().equals(event.getOption()))
{ {
WidgetMenuOptionClicked customMenu = new WidgetMenuOptionClicked(); WidgetMenuOptionClicked customMenu = WidgetMenuOptionClicked.INSTANCE;
customMenu.setMenuOption(event.getOption()); customMenu.setMenuOption(event.getOption());
customMenu.setMenuTarget(event.getTarget()); customMenu.setMenuTarget(event.getTarget());
customMenu.setWidget(curMenuOption.getWidget()); customMenu.setWidget(curMenuOption.getWidget());
@@ -444,7 +444,7 @@ public class MenuManager
// <col=ffffff>username<col=40ff00> (level-42) or <col=ffffff><img=2>username</col> // <col=ffffff>username<col=40ff00> (level-42) or <col=ffffff><img=2>username</col>
String username = Text.removeTags(target).split("[(]")[0].trim(); String username = Text.removeTags(target).split("[(]")[0].trim();
PlayerMenuOptionClicked playerMenuOptionClicked = new PlayerMenuOptionClicked(); PlayerMenuOptionClicked playerMenuOptionClicked = PlayerMenuOptionClicked.INSTANCE;
playerMenuOptionClicked.setMenuOption(event.getOption()); playerMenuOptionClicked.setMenuOption(event.getOption());
playerMenuOptionClicked.setMenuTarget(username); playerMenuOptionClicked.setMenuTarget(username);

View File

@@ -258,7 +258,7 @@ public class DevToolsPlugin extends Plugin
int value = Integer.parseInt(args[1]); int value = Integer.parseInt(args[1]);
client.setVarpValue(client.getVarps(), varp, value); client.setVarpValue(client.getVarps(), varp, value);
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set VarPlayer " + varp + " to " + value, null); client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set VarPlayer " + varp + " to " + value, null);
VarbitChanged varbitChanged = new VarbitChanged(); VarbitChanged varbitChanged = VarbitChanged.INSTANCE;
varbitChanged.setIndex(varp); varbitChanged.setIndex(varp);
eventBus.post(varbitChanged); // fake event eventBus.post(varbitChanged); // fake event
break; break;
@@ -276,7 +276,7 @@ public class DevToolsPlugin extends Plugin
int value = Integer.parseInt(args[1]); int value = Integer.parseInt(args[1]);
client.setVarbitValue(client.getVarps(), varbit, value); client.setVarbitValue(client.getVarps(), varbit, value);
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set varbit " + varbit + " to " + value, null); client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set varbit " + varbit + " to " + value, null);
eventBus.post(new VarbitChanged()); // fake event eventBus.post(VarbitChanged.INSTANCE); // fake event
break; break;
} }
case "addxp": case "addxp":
@@ -293,7 +293,7 @@ public class DevToolsPlugin extends Plugin
client.queueChangedSkill(skill); client.queueChangedSkill(skill);
ExperienceChanged experienceChanged = new ExperienceChanged(); ExperienceChanged experienceChanged = ExperienceChanged.INSTANCE;
experienceChanged.setSkill(skill); experienceChanged.setSkill(skill);
eventBus.post(experienceChanged); eventBus.post(experienceChanged);
break; break;
@@ -312,11 +312,11 @@ public class DevToolsPlugin extends Plugin
client.queueChangedSkill(skill); client.queueChangedSkill(skill);
ExperienceChanged experienceChanged = new ExperienceChanged(); ExperienceChanged experienceChanged = ExperienceChanged.INSTANCE;
experienceChanged.setSkill(skill); experienceChanged.setSkill(skill);
eventBus.post(experienceChanged); eventBus.post(experienceChanged);
BoostedLevelChanged boostedLevelChanged = new BoostedLevelChanged(); BoostedLevelChanged boostedLevelChanged = BoostedLevelChanged.INSTANCE;
boostedLevelChanged.setSkill(skill); boostedLevelChanged.setSkill(skill);
eventBus.post(boostedLevelChanged); eventBus.post(boostedLevelChanged);
break; break;

View File

@@ -121,7 +121,7 @@ public class FreezeTimersPlugin extends Plugin
{ {
if (prayerTracker.getSpotanimLastTick(actor) != actor.getSpotAnimation()) if (prayerTracker.getSpotanimLastTick(actor) != actor.getSpotAnimation())
{ {
SpotAnimationChanged callback = new SpotAnimationChanged(); SpotAnimationChanged callback = SpotAnimationChanged.INSTANCE;
callback.setActor(actor); callback.setActor(actor);
client.getCallbacks().post(callback); client.getCallbacks().post(callback);
} }

View File

@@ -118,7 +118,9 @@ public class GameEventManager
if (itemContainer != null) if (itemContainer != null)
{ {
eventBus.post(new ItemContainerChanged(itemContainer)); ItemContainerChanged event = ItemContainerChanged.INSTANCE;
event.setItemContainer(itemContainer);
eventBus.post(event);
} }
} }
@@ -126,7 +128,8 @@ public class GameEventManager
{ {
if (npc != null) if (npc != null)
{ {
final NpcSpawned npcSpawned = new NpcSpawned(npc); final NpcSpawned npcSpawned = NpcSpawned.INSTANCE;
npcSpawned.setNpc(npc);
eventBus.post(npcSpawned); eventBus.post(npcSpawned);
} }
} }
@@ -135,7 +138,8 @@ public class GameEventManager
{ {
if (player != null) if (player != null)
{ {
final PlayerSpawned playerSpawned = new PlayerSpawned(player); final PlayerSpawned playerSpawned = PlayerSpawned.INSTANCE;
playerSpawned.setPlayer(player);
eventBus.post(playerSpawned); eventBus.post(playerSpawned);
} }
} }
@@ -144,7 +148,7 @@ public class GameEventManager
{ {
Optional.ofNullable(tile.getWallObject()).ifPresent(object -> Optional.ofNullable(tile.getWallObject()).ifPresent(object ->
{ {
final WallObjectSpawned objectSpawned = new WallObjectSpawned(); final WallObjectSpawned objectSpawned = WallObjectSpawned.INSTANCE;
objectSpawned.setTile(tile); objectSpawned.setTile(tile);
objectSpawned.setWallObject(object); objectSpawned.setWallObject(object);
eventBus.post(objectSpawned); eventBus.post(objectSpawned);
@@ -152,7 +156,7 @@ public class GameEventManager
Optional.ofNullable(tile.getDecorativeObject()).ifPresent(object -> Optional.ofNullable(tile.getDecorativeObject()).ifPresent(object ->
{ {
final DecorativeObjectSpawned objectSpawned = new DecorativeObjectSpawned(); final DecorativeObjectSpawned objectSpawned = DecorativeObjectSpawned.INSTANCE;
objectSpawned.setTile(tile); objectSpawned.setTile(tile);
objectSpawned.setDecorativeObject(object); objectSpawned.setDecorativeObject(object);
eventBus.post(objectSpawned); eventBus.post(objectSpawned);
@@ -160,7 +164,7 @@ public class GameEventManager
Optional.ofNullable(tile.getGroundObject()).ifPresent(object -> Optional.ofNullable(tile.getGroundObject()).ifPresent(object ->
{ {
final GroundObjectSpawned objectSpawned = new GroundObjectSpawned(); final GroundObjectSpawned objectSpawned = GroundObjectSpawned.INSTANCE;
objectSpawned.setTile(tile); objectSpawned.setTile(tile);
objectSpawned.setGroundObject(object); objectSpawned.setGroundObject(object);
eventBus.post(objectSpawned); eventBus.post(objectSpawned);
@@ -170,7 +174,7 @@ public class GameEventManager
.filter(Objects::nonNull) .filter(Objects::nonNull)
.forEach(object -> .forEach(object ->
{ {
final GameObjectSpawned objectSpawned = new GameObjectSpawned(); final GameObjectSpawned objectSpawned = GameObjectSpawned.INSTANCE;
objectSpawned.setTile(tile); objectSpawned.setTile(tile);
objectSpawned.setGameObject(object); objectSpawned.setGameObject(object);
eventBus.post(objectSpawned); eventBus.post(objectSpawned);
@@ -186,7 +190,9 @@ public class GameEventManager
current = current.getNext(); current = current.getNext();
final ItemSpawned itemSpawned = new ItemSpawned(tile, item); final ItemSpawned itemSpawned = ItemSpawned.INSTANCE;
itemSpawned.setItem(item);
itemSpawned.setTile(tile);
eventBus.post(itemSpawned); eventBus.post(itemSpawned);
} }
}); });

View File

@@ -93,14 +93,14 @@ public class AttackStylesPluginTest
when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal()); when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal());
// verify that earning xp in a warned skill will display red text on the widget // verify that earning xp in a warned skill will display red text on the widget
attackPlugin.onVarbitChanged(new VarbitChanged()); attackPlugin.onVarbitChanged(VarbitChanged.INSTANCE);
assertTrue(attackPlugin.isWarnedSkillSelected()); assertTrue(attackPlugin.isWarnedSkillSelected());
// Switch to attack style that doesn't give attack xp // Switch to attack style that doesn't give attack xp
when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal()); when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal());
// Verify the widget will now display white text // Verify the widget will now display white text
attackPlugin.onVarbitChanged(new VarbitChanged()); attackPlugin.onVarbitChanged(VarbitChanged.INSTANCE);
warnedSkills = attackPlugin.getWarnedSkills(); warnedSkills = attackPlugin.getWarnedSkills();
assertTrue(warnedSkills.contains(Skill.ATTACK)); assertTrue(warnedSkills.contains(Skill.ATTACK));
assertFalse(attackPlugin.isWarnedSkillSelected()); assertFalse(attackPlugin.isWarnedSkillSelected());
@@ -129,7 +129,7 @@ public class AttackStylesPluginTest
// equip type_4 weapon type on player // equip type_4 weapon type on player
when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(WeaponType.TYPE_4.ordinal()); when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(WeaponType.TYPE_4.ordinal());
attackPlugin.onVarbitChanged(new VarbitChanged()); attackPlugin.onVarbitChanged(VarbitChanged.INSTANCE);
// Verify there is a warned skill // Verify there is a warned skill
Set<Skill> warnedSkills = attackPlugin.getWarnedSkills(); Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();

View File

@@ -71,7 +71,7 @@ public class CerberusPluginTest
mockNpc(new LocalPoint(2, 5)), mockNpc(new LocalPoint(2, 5)),
mockNpc(new LocalPoint(1, 5)) mockNpc(new LocalPoint(1, 5))
)); ));
cerberusPlugin.onGameTick(new GameTick()); cerberusPlugin.onGameTick(GameTick.INSTANCE);
// Expected sort is by lowest y first, then by lowest x // Expected sort is by lowest y first, then by lowest x
assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0)); assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0));

View File

@@ -83,7 +83,7 @@ public class ChatNotificationsPluginTest
MessageNode messageNode = mock(MessageNode.class); MessageNode messageNode = mock(MessageNode.class);
when(messageNode.getValue()).thenReturn("Deathbeam, Deathbeam OSRS"); when(messageNode.getValue()).thenReturn("Deathbeam, Deathbeam OSRS");
ChatMessage chatMessage = new ChatMessage(); ChatMessage chatMessage = ChatMessage.INSTANCE;
chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setType(ChatMessageType.PUBLICCHAT);
chatMessage.setMessageNode(messageNode); chatMessage.setMessageNode(messageNode);

View File

@@ -118,7 +118,7 @@ public class CookingPluginTest
when(config.fermentTimer()).thenReturn(true); when(config.fermentTimer()).thenReturn(true);
when(client.getLocalPlayer()).thenReturn(player); when(client.getLocalPlayer()).thenReturn(player);
SpotAnimationChanged graphicChanged = new SpotAnimationChanged(); SpotAnimationChanged graphicChanged = SpotAnimationChanged.INSTANCE;
graphicChanged.setActor(player); graphicChanged.setActor(player);
cookingPlugin.onSpotAnimationChanged(graphicChanged); cookingPlugin.onSpotAnimationChanged(graphicChanged);

View File

@@ -73,7 +73,7 @@ public class EmojiPluginTest
when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class)); when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class));
// Trip emoji loading // Trip emoji loading
GameStateChanged gameStateChanged = new GameStateChanged(); GameStateChanged gameStateChanged = GameStateChanged.INSTANCE;
gameStateChanged.setGameState(GameState.LOGGED_IN); gameStateChanged.setGameState(GameState.LOGGED_IN);
emojiPlugin.onGameStateChanged(gameStateChanged); emojiPlugin.onGameStateChanged(gameStateChanged);
@@ -81,7 +81,7 @@ public class EmojiPluginTest
// With chat recolor, message may be wrapped in col tags // With chat recolor, message may be wrapped in col tags
when(messageNode.getValue()).thenReturn("<col=ff0000>:) :) :)</col>"); when(messageNode.getValue()).thenReturn("<col=ff0000>:) :) :)</col>");
ChatMessage chatMessage = new ChatMessage(); ChatMessage chatMessage = ChatMessage.INSTANCE;
chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setType(ChatMessageType.PUBLICCHAT);
chatMessage.setMessageNode(messageNode); chatMessage.setMessageNode(messageNode);
@@ -98,14 +98,14 @@ public class EmojiPluginTest
when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class)); when(client.createIndexedSprite()).thenReturn(mock(IndexedSprite.class));
// Trip emoji loading // Trip emoji loading
GameStateChanged gameStateChanged = new GameStateChanged(); GameStateChanged gameStateChanged = GameStateChanged.INSTANCE;
gameStateChanged.setGameState(GameState.LOGGED_IN); gameStateChanged.setGameState(GameState.LOGGED_IN);
emojiPlugin.onGameStateChanged(gameStateChanged); emojiPlugin.onGameStateChanged(gameStateChanged);
MessageNode messageNode = mock(MessageNode.class); MessageNode messageNode = mock(MessageNode.class);
when(messageNode.getValue()).thenReturn("<gt>:D<lt>"); when(messageNode.getValue()).thenReturn("<gt>:D<lt>");
ChatMessage chatMessage = new ChatMessage(); ChatMessage chatMessage = ChatMessage.INSTANCE;
chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setType(ChatMessageType.PUBLICCHAT);
chatMessage.setMessageNode(messageNode); chatMessage.setMessageNode(messageNode);

View File

@@ -132,13 +132,13 @@ public class IdleNotifierPluginTest
public void checkAnimationIdle() public void checkAnimationIdle()
{ {
when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE);
AnimationChanged animationChanged = new AnimationChanged(); AnimationChanged animationChanged = AnimationChanged.INSTANCE;
animationChanged.setActor(player); animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
when(player.getAnimation()).thenReturn(AnimationID.IDLE); when(player.getAnimation()).thenReturn(AnimationID.IDLE);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!"); verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!");
} }
@@ -146,16 +146,16 @@ public class IdleNotifierPluginTest
public void checkAnimationReset() public void checkAnimationReset()
{ {
when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE);
AnimationChanged animationChanged = new AnimationChanged(); AnimationChanged animationChanged = AnimationChanged.INSTANCE;
animationChanged.setActor(player); animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO); when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
when(player.getAnimation()).thenReturn(AnimationID.IDLE); when(player.getAnimation()).thenReturn(AnimationID.IDLE);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any()); verify(notifier, times(0)).notify(any());
} }
@@ -163,14 +163,14 @@ public class IdleNotifierPluginTest
public void checkAnimationLogout() public void checkAnimationLogout()
{ {
when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE); when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE);
AnimationChanged animationChanged = new AnimationChanged(); AnimationChanged animationChanged = AnimationChanged.INSTANCE;
animationChanged.setActor(player); animationChanged.setActor(player);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
// Logout // Logout
when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN);
GameStateChanged gameStateChanged = new GameStateChanged(); GameStateChanged gameStateChanged = GameStateChanged.INSTANCE;
gameStateChanged.setGameState(GameState.LOGIN_SCREEN); gameStateChanged.setGameState(GameState.LOGIN_SCREEN);
plugin.onGameStateChanged(gameStateChanged); plugin.onGameStateChanged(gameStateChanged);
@@ -182,7 +182,7 @@ public class IdleNotifierPluginTest
// Tick // Tick
when(player.getAnimation()).thenReturn(AnimationID.IDLE); when(player.getAnimation()).thenReturn(AnimationID.IDLE);
plugin.onAnimationChanged(animationChanged); plugin.onAnimationChanged(animationChanged);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any()); verify(notifier, times(0)).notify(any());
} }
@@ -190,11 +190,16 @@ public class IdleNotifierPluginTest
public void checkCombatIdle() public void checkCombatIdle()
{ {
when(player.getInteracting()).thenReturn(monster); when(player.getInteracting()).thenReturn(monster);
plugin.onInteractingChanged(new InteractingChanged(player, monster)); InteractingChanged event = InteractingChanged.INSTANCE;
plugin.onGameTick(new GameTick()); event.setSource(player);
event.setTarget(monster);
plugin.onInteractingChanged(event);
plugin.onGameTick(GameTick.INSTANCE);
when(player.getInteracting()).thenReturn(null); when(player.getInteracting()).thenReturn(null);
plugin.onInteractingChanged(new InteractingChanged(player, null)); event.setSource(player);
plugin.onGameTick(new GameTick()); event.setTarget(null);
plugin.onInteractingChanged(event);
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify("[" + PLAYER_NAME + "] is now out of combat!"); verify(notifier).notify("[" + PLAYER_NAME + "] is now out of combat!");
} }
@@ -202,27 +207,37 @@ public class IdleNotifierPluginTest
public void checkCombatReset() public void checkCombatReset()
{ {
when(player.getInteracting()).thenReturn(monster); when(player.getInteracting()).thenReturn(monster);
plugin.onInteractingChanged(new InteractingChanged(player, monster)); InteractingChanged event = InteractingChanged.INSTANCE;
plugin.onGameTick(new GameTick()); event.setSource(player);
event.setTarget(monster);
plugin.onInteractingChanged(event);
plugin.onGameTick(GameTick.INSTANCE);
when(player.getInteracting()).thenReturn(randomEvent); when(player.getInteracting()).thenReturn(randomEvent);
plugin.onInteractingChanged(new InteractingChanged(player, randomEvent)); event.setSource(player);
plugin.onGameTick(new GameTick()); event.setTarget(randomEvent);
plugin.onInteractingChanged(event);
plugin.onGameTick(GameTick.INSTANCE);
when(player.getInteracting()).thenReturn(null); when(player.getInteracting()).thenReturn(null);
plugin.onInteractingChanged(new InteractingChanged(player, null)); event.setSource(player);
plugin.onGameTick(new GameTick()); event.setTarget(null);
plugin.onInteractingChanged(event);
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any()); verify(notifier, times(0)).notify(any());
} }
@Test @Test
public void checkCombatLogout() public void checkCombatLogout()
{ {
plugin.onInteractingChanged(new InteractingChanged(player, monster)); InteractingChanged event = InteractingChanged.INSTANCE;
event.setSource(player);
event.setTarget(monster);
plugin.onInteractingChanged(event);
when(player.getInteracting()).thenReturn(monster); when(player.getInteracting()).thenReturn(monster);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
// Logout // Logout
when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN);
GameStateChanged gameStateChanged = new GameStateChanged(); GameStateChanged gameStateChanged = GameStateChanged.INSTANCE;
gameStateChanged.setGameState(GameState.LOGIN_SCREEN); gameStateChanged.setGameState(GameState.LOGIN_SCREEN);
plugin.onGameStateChanged(gameStateChanged); plugin.onGameStateChanged(gameStateChanged);
@@ -233,8 +248,10 @@ public class IdleNotifierPluginTest
// Tick // Tick
when(player.getInteracting()).thenReturn(null); when(player.getInteracting()).thenReturn(null);
plugin.onInteractingChanged(new InteractingChanged(player, null)); event.setSource(player);
plugin.onGameTick(new GameTick()); event.setTarget(null);
plugin.onInteractingChanged(event);
plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any()); verify(notifier, times(0)).notify(any());
} }
@@ -245,11 +262,11 @@ public class IdleNotifierPluginTest
when(client.getMouseIdleTicks()).thenReturn(80_000); when(client.getMouseIdleTicks()).thenReturn(80_000);
// But player is being damaged (is in combat) // But player is being damaged (is in combat)
final HitsplatApplied hitsplatApplied = new HitsplatApplied(); final HitsplatApplied hitsplatApplied = HitsplatApplied.INSTANCE;
hitsplatApplied.setActor(player); hitsplatApplied.setActor(player);
hitsplatApplied.setHitsplat(new Hitsplat(Hitsplat.HitsplatType.DAMAGE, 0, 0)); hitsplatApplied.setHitsplat(new Hitsplat(Hitsplat.HitsplatType.DAMAGE, 0, 0));
plugin.onHitsplatApplied(hitsplatApplied); plugin.onHitsplatApplied(hitsplatApplied);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(0)).notify(any()); verify(notifier, times(0)).notify(any());
} }
@@ -262,8 +279,8 @@ public class IdleNotifierPluginTest
when(client.getKeyboardIdleTicks()).thenReturn(80_000); when(client.getKeyboardIdleTicks()).thenReturn(80_000);
when(client.getMouseIdleTicks()).thenReturn(14_500); when(client.getMouseIdleTicks()).thenReturn(14_500);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
verify(notifier, times(1)).notify(any()); verify(notifier, times(1)).notify(any());
} }
@@ -273,11 +290,11 @@ public class IdleNotifierPluginTest
when(config.getSpecEnergyThreshold()).thenReturn(50); when(config.getSpecEnergyThreshold()).thenReturn(50);
when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(400); // 40% when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(400); // 40%
plugin.onGameTick(new GameTick()); // once to set lastSpecEnergy to 400 plugin.onGameTick(GameTick.INSTANCE); // once to set lastSpecEnergy to 400
verify(notifier, never()).notify(any()); verify(notifier, never()).notify(any());
when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(500); // 50% when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(500); // 50%
plugin.onGameTick(new GameTick()); plugin.onGameTick(GameTick.INSTANCE);
verify(notifier).notify(Matchers.eq("[" + PLAYER_NAME + "] has restored spec energy!")); verify(notifier).notify(Matchers.eq("[" + PLAYER_NAME + "] has restored spec energy!"));
} }
} }

View File

@@ -115,13 +115,13 @@ public class MotherlodePluginTest
public void testOreCounter() public void testOreCounter()
{ {
// set inMlm // set inMlm
GameStateChanged gameStateChanged = new GameStateChanged(); GameStateChanged gameStateChanged = GameStateChanged.INSTANCE;
gameStateChanged.setGameState(GameState.LOGGED_IN); gameStateChanged.setGameState(GameState.LOGGED_IN);
motherlodePlugin.onGameStateChanged(gameStateChanged); motherlodePlugin.onGameStateChanged(gameStateChanged);
// Initial sack count // Initial sack count
when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(42); when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(42);
motherlodePlugin.onVarbitChanged(new VarbitChanged()); motherlodePlugin.onVarbitChanged(VarbitChanged.INSTANCE);
// Create before inventory // Create before inventory
ItemContainer inventory = mock(ItemContainer.class); ItemContainer inventory = mock(ItemContainer.class);
@@ -140,7 +140,7 @@ public class MotherlodePluginTest
// Withdraw 20 // Withdraw 20
when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(22); when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(22);
motherlodePlugin.onVarbitChanged(new VarbitChanged()); motherlodePlugin.onVarbitChanged(VarbitChanged.INSTANCE);
inventory = mock(ItemContainer.class); inventory = mock(ItemContainer.class);
// +1 rune, +4 nugget, +2 coal, +1 addy // +1 rune, +4 nugget, +2 coal, +1 addy
@@ -162,7 +162,9 @@ public class MotherlodePluginTest
when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory); when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory);
// Trigger comparison // Trigger comparison
motherlodePlugin.onItemContainerChanged(new ItemContainerChanged(inventory)); ItemContainerChanged event = ItemContainerChanged.INSTANCE;
event.setItemContainer(inventory);
motherlodePlugin.onItemContainerChanged(event);
verify(motherlodeSession).updateOreFound(ItemID.RUNITE_ORE, 1); verify(motherlodeSession).updateOreFound(ItemID.RUNITE_ORE, 1);
verify(motherlodeSession).updateOreFound(ItemID.GOLDEN_NUGGET, 4); verify(motherlodeSession).updateOreFound(ItemID.GOLDEN_NUGGET, 4);

View File

@@ -175,11 +175,11 @@ public class ScreenshotPluginTest
assertEquals("Hitpoints(99)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL)); assertEquals("Hitpoints(99)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL));
WidgetLoaded event = new WidgetLoaded(); WidgetLoaded event = WidgetLoaded.INSTANCE;
event.setGroupId(LEVEL_UP_GROUP_ID); event.setGroupId(LEVEL_UP_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event); screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick(); GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick); screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
@@ -198,11 +198,11 @@ public class ScreenshotPluginTest
assertEquals("Firemaking(9)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL)); assertEquals("Firemaking(9)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL));
WidgetLoaded event = new WidgetLoaded(); WidgetLoaded event = WidgetLoaded.INSTANCE;
event.setGroupId(LEVEL_UP_GROUP_ID); event.setGroupId(LEVEL_UP_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event); screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick(); GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick); screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
@@ -221,11 +221,11 @@ public class ScreenshotPluginTest
assertEquals("Attack(70)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL)); assertEquals("Attack(70)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL));
WidgetLoaded event = new WidgetLoaded(); WidgetLoaded event = WidgetLoaded.INSTANCE;
event.setGroupId(LEVEL_UP_GROUP_ID); event.setGroupId(LEVEL_UP_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event); screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick(); GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick); screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
@@ -244,11 +244,11 @@ public class ScreenshotPluginTest
assertEquals("Hunter(2)", screenshotPlugin.parseLevelUpWidget(DIALOG_SPRITE_TEXT)); assertEquals("Hunter(2)", screenshotPlugin.parseLevelUpWidget(DIALOG_SPRITE_TEXT));
WidgetLoaded event = new WidgetLoaded(); WidgetLoaded event = WidgetLoaded.INSTANCE;
event.setGroupId(DIALOG_SPRITE_GROUP_ID); event.setGroupId(DIALOG_SPRITE_GROUP_ID);
screenshotPlugin.onWidgetLoaded(event); screenshotPlugin.onWidgetLoaded(event);
GameTick tick = new GameTick(); GameTick tick = GameTick.INSTANCE;
screenshotPlugin.onGameTick(tick); screenshotPlugin.onGameTick(tick);
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));

View File

@@ -155,7 +155,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW); when(npcDialog.getText()).thenReturn(TASK_NEW);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(231, slayerPlugin.getCurrentTask().getAmount()); assertEquals(231, slayerPlugin.getCurrentTask().getAmount());
@@ -167,7 +167,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR); when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Wyrms", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Wyrms", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(147, slayerPlugin.getCurrentTask().getAmount()); assertEquals(147, slayerPlugin.getCurrentTask().getAmount());
@@ -180,7 +180,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_2); when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_2);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Hellhounds", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Hellhounds", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(142, slayerPlugin.getCurrentTask().getAmount()); assertEquals(142, slayerPlugin.getCurrentTask().getAmount());
@@ -193,7 +193,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_3); when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_3);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Trolls", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Trolls", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(135, slayerPlugin.getCurrentTask().getAmount()); assertEquals(135, slayerPlugin.getCurrentTask().getAmount());
@@ -206,7 +206,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST); when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("goblins", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("goblins", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(17, slayerPlugin.getCurrentTask().getAmount()); assertEquals(17, slayerPlugin.getCurrentTask().getAmount());
@@ -218,7 +218,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_NEW_NPC_CONTACT); when(npcDialog.getText()).thenReturn(TASK_NEW_NPC_CONTACT);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(211, slayerPlugin.getCurrentTask().getAmount()); assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
@@ -230,7 +230,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW); when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Vet'ion", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Vet'ion", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(3, slayerPlugin.getCurrentTask().getAmount()); assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
@@ -243,7 +243,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW_THE); when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW_THE);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("Chaos Elemental", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("Chaos Elemental", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(3, slayerPlugin.getCurrentTask().getAmount()); assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
@@ -296,7 +296,7 @@ public class SlayerPluginTest
Widget npcDialog = mock(Widget.class); Widget npcDialog = mock(Widget.class);
when(npcDialog.getText()).thenReturn(TASK_EXISTING); when(npcDialog.getText()).thenReturn(TASK_EXISTING);
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
slayerPlugin.onGameTick(new GameTick()); slayerPlugin.onGameTick(GameTick.INSTANCE);
assertEquals("suqahs", slayerPlugin.getCurrentTask().getTaskName()); assertEquals("suqahs", slayerPlugin.getCurrentTask().getTaskName());
assertEquals(222, slayerPlugin.getCurrentTask().getAmount()); assertEquals(222, slayerPlugin.getCurrentTask().getAmount());
@@ -331,7 +331,7 @@ public class SlayerPluginTest
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_POINTS, null, 0); ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_POINTS, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent); slayerPlugin.onChatMessage(chatMessageEvent);
VarbitChanged varbitChanged = new VarbitChanged(); VarbitChanged varbitChanged = VarbitChanged.INSTANCE;
slayerPlugin.onVarbitChanged(varbitChanged); slayerPlugin.onVarbitChanged(varbitChanged);
assertEquals(9, slayerPlugin.getStreak()); assertEquals(9, slayerPlugin.getStreak());
@@ -347,7 +347,7 @@ public class SlayerPluginTest
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_LARGE_STREAK, null, 0); ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_LARGE_STREAK, null, 0);
slayerPlugin.onChatMessage(chatMessageEvent); slayerPlugin.onChatMessage(chatMessageEvent);
VarbitChanged varbitChanged = new VarbitChanged(); VarbitChanged varbitChanged = VarbitChanged.INSTANCE;
slayerPlugin.onVarbitChanged(varbitChanged); slayerPlugin.onVarbitChanged(varbitChanged);
assertEquals(2465, slayerPlugin.getStreak()); assertEquals(2465, slayerPlugin.getStreak());
@@ -408,7 +408,7 @@ public class SlayerPluginTest
when(slayerConfig.taskCommand()).thenReturn(true); when(slayerConfig.taskCommand()).thenReturn(true);
when(chatClient.getTask(anyString())).thenReturn(task); when(chatClient.getTask(anyString())).thenReturn(task);
ChatMessage setMessage = new ChatMessage(); ChatMessage setMessage = ChatMessage.INSTANCE;
setMessage.setType(ChatMessageType.PUBLICCHAT); setMessage.setType(ChatMessageType.PUBLICCHAT);
setMessage.setName("Adam"); setMessage.setName("Adam");
setMessage.setMessageNode(mock(MessageNode.class)); setMessage.setMessageNode(mock(MessageNode.class));
@@ -430,7 +430,7 @@ public class SlayerPluginTest
when(slayerConfig.taskCommand()).thenReturn(true); when(slayerConfig.taskCommand()).thenReturn(true);
when(chatClient.getTask(anyString())).thenReturn(task); when(chatClient.getTask(anyString())).thenReturn(task);
ChatMessage chatMessage = new ChatMessage(); ChatMessage chatMessage = ChatMessage.INSTANCE;
chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setType(ChatMessageType.PUBLICCHAT);
chatMessage.setName("Adam"); chatMessage.setName("Adam");
chatMessage.setMessageNode(mock(MessageNode.class)); chatMessage.setMessageNode(mock(MessageNode.class));

View File

@@ -186,7 +186,7 @@ public abstract class RSActorMixin implements RSActor
@Inject @Inject
public void animationChanged(int idx) public void animationChanged(int idx)
{ {
AnimationChanged animationChange = new AnimationChanged(); AnimationChanged animationChange = AnimationChanged.INSTANCE;
animationChange.setActor(this); animationChange.setActor(this);
client.getCallbacks().post(animationChange); client.getCallbacks().post(animationChange);
} }
@@ -195,7 +195,7 @@ public abstract class RSActorMixin implements RSActor
@Inject @Inject
public void spotAnimationChanged(int idx) public void spotAnimationChanged(int idx)
{ {
SpotAnimationChanged spotAnimationChanged = new SpotAnimationChanged(); SpotAnimationChanged spotAnimationChanged = SpotAnimationChanged.INSTANCE;
spotAnimationChanged.setActor(this); spotAnimationChanged.setActor(this);
client.getCallbacks().post(spotAnimationChanged); client.getCallbacks().post(spotAnimationChanged);
} }
@@ -204,7 +204,9 @@ public abstract class RSActorMixin implements RSActor
@Inject @Inject
public void interactingChanged(int idx) public void interactingChanged(int idx)
{ {
InteractingChanged interactingChanged = new InteractingChanged(this, getInteracting()); InteractingChanged interactingChanged = InteractingChanged.INSTANCE;
interactingChanged.setSource(this);
interactingChanged.setTarget(getInteracting());
client.getCallbacks().post(interactingChanged); client.getCallbacks().post(interactingChanged);
} }
@@ -215,7 +217,10 @@ public abstract class RSActorMixin implements RSActor
String overheadText = getOverheadText(); String overheadText = getOverheadText();
if (overheadText != null) if (overheadText != null)
{ {
OverheadTextChanged overheadTextChanged = new OverheadTextChanged(this, overheadText);
OverheadTextChanged overheadTextChanged = OverheadTextChanged.INSTANCE;
overheadTextChanged.setActor(this);
overheadTextChanged.setOverheadText(overheadText);
client.getCallbacks().post(overheadTextChanged); client.getCallbacks().post(overheadTextChanged);
} }
} }
@@ -251,7 +256,7 @@ public abstract class RSActorMixin implements RSActor
{ {
client.getLogger().debug("You died!"); client.getLogger().debug("You died!");
LocalPlayerDeath event = new LocalPlayerDeath(); LocalPlayerDeath event = LocalPlayerDeath.INSTANCE;
client.getCallbacks().post(event); client.getCallbacks().post(event);
} }
else if (this instanceof RSNPC) else if (this instanceof RSNPC)
@@ -278,7 +283,7 @@ public abstract class RSActorMixin implements RSActor
public void applyActorHitsplat(int type, int value, int var3, int var4, int gameCycle, int duration) public void applyActorHitsplat(int type, int value, int var3, int var4, int gameCycle, int duration)
{ {
final Hitsplat hitsplat = new Hitsplat(Hitsplat.HitsplatType.fromInteger(type), value, gameCycle + duration); final Hitsplat hitsplat = new Hitsplat(Hitsplat.HitsplatType.fromInteger(type), value, gameCycle + duration);
final HitsplatApplied event = new HitsplatApplied(); final HitsplatApplied event = HitsplatApplied.INSTANCE;
event.setActor(this); event.setActor(this);
event.setHitsplat(hitsplat); event.setHitsplat(hitsplat);
client.getCallbacks().post(event); client.getCallbacks().post(event);

View File

@@ -27,7 +27,8 @@ public abstract class RSClanChatMixin implements RSClanChat
return; return;
} }
ClanMemberJoined event = new ClanMemberJoined(member); ClanMemberJoined event = ClanMemberJoined.INSTANCE;
event.setMember(member);
client.getCallbacks().postDeferred(event); client.getCallbacks().postDeferred(event);
} }
@@ -41,7 +42,8 @@ public abstract class RSClanChatMixin implements RSClanChat
return; return;
} }
ClanMemberLeft event = new ClanMemberLeft(member); ClanMemberLeft event = ClanMemberLeft.INSTANCE;
event.setMember(member);
client.getCallbacks().postDeferred(event); client.getCallbacks().postDeferred(event);
} }
} }

View File

@@ -867,7 +867,7 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
public static void draggingWidgetChanged(int idx) public static void draggingWidgetChanged(int idx)
{ {
DraggingWidgetChanged draggingWidgetChanged = new DraggingWidgetChanged(); DraggingWidgetChanged draggingWidgetChanged = DraggingWidgetChanged.INSTANCE;
draggingWidgetChanged.setDraggingWidget(client.isDraggingWidget()); draggingWidgetChanged.setDraggingWidget(client.isDraggingWidget());
client.getCallbacks().post(draggingWidgetChanged); client.getCallbacks().post(draggingWidgetChanged);
} }
@@ -905,7 +905,7 @@ public abstract class RSClientMixin implements RSClient
if (loaded) if (loaded)
{ {
WidgetLoaded event = new WidgetLoaded(); WidgetLoaded event = WidgetLoaded.INSTANCE;
event.setGroupId(groupId); event.setGroupId(groupId);
client.getCallbacks().post(event); client.getCallbacks().post(event);
} }
@@ -937,7 +937,7 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
public static void experiencedChanged(int idx) public static void experiencedChanged(int idx)
{ {
ExperienceChanged experienceChanged = new ExperienceChanged(); ExperienceChanged experienceChanged = ExperienceChanged.INSTANCE;
Skill[] possibleSkills = Skill.values(); Skill[] possibleSkills = Skill.values();
// We subtract one here because 'Overall' isn't considered a skill that's updated. // We subtract one here because 'Overall' isn't considered a skill that's updated.
@@ -958,7 +958,7 @@ public abstract class RSClientMixin implements RSClient
if (idx >= 0 && idx < skills.length - 1) if (idx >= 0 && idx < skills.length - 1)
{ {
Skill updatedSkill = skills[idx]; Skill updatedSkill = skills[idx];
BoostedLevelChanged boostedLevelChanged = new BoostedLevelChanged(); BoostedLevelChanged boostedLevelChanged = BoostedLevelChanged.INSTANCE;
boostedLevelChanged.setSkill(updatedSkill); boostedLevelChanged.setSkill(updatedSkill);
client.getCallbacks().post(boostedLevelChanged); client.getCallbacks().post(boostedLevelChanged);
} }
@@ -977,7 +977,7 @@ public abstract class RSClientMixin implements RSClient
client.getPlayerMenuTypes()[idx] = playerAction.getId(); client.getPlayerMenuTypes()[idx] = playerAction.getId();
} }
PlayerMenuOptionsChanged optionsChanged = new PlayerMenuOptionsChanged(); PlayerMenuOptionsChanged optionsChanged = PlayerMenuOptionsChanged.INSTANCE;
optionsChanged.setIndex(idx); optionsChanged.setIndex(idx);
client.getCallbacks().post(optionsChanged); client.getCallbacks().post(optionsChanged);
} }
@@ -986,7 +986,7 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
public static void gameStateChanged(int idx) public static void gameStateChanged(int idx)
{ {
GameStateChanged gameStateChange = new GameStateChanged(); GameStateChanged gameStateChange = GameStateChanged.INSTANCE;
gameStateChange.setGameState(client.getGameState()); gameStateChange.setGameState(client.getGameState());
client.getCallbacks().post(gameStateChange); client.getCallbacks().post(gameStateChange);
} }
@@ -1007,7 +1007,9 @@ public abstract class RSClientMixin implements RSClient
{ {
npc.setIndex(idx); npc.setIndex(idx);
client.getCallbacks().postDeferred(new NpcSpawned(npc)); NpcSpawned npcSpawned = NpcSpawned.INSTANCE;
npcSpawned.setNpc(npc);
client.getCallbacks().postDeferred(npcSpawned);
} }
} }
@@ -1027,11 +1029,15 @@ public abstract class RSClientMixin implements RSClient
if (oldPlayer != null) if (oldPlayer != null)
{ {
client.getCallbacks().post(new PlayerDespawned(oldPlayer)); PlayerDespawned playerDespawned = PlayerDespawned.INSTANCE;
playerDespawned.setPlayer(oldPlayer);
client.getCallbacks().post(playerDespawned);
} }
if (player != null) if (player != null)
{ {
client.getCallbacks().postDeferred(new PlayerSpawned(player)); PlayerSpawned playerSpawned = PlayerSpawned.INSTANCE;
playerSpawned.setPlayer(player);
client.getCallbacks().postDeferred(playerSpawned);
} }
} }
@@ -1051,7 +1057,7 @@ public abstract class RSClientMixin implements RSClient
return; return;
} }
GrandExchangeOfferChanged offerChangedEvent = new GrandExchangeOfferChanged(); GrandExchangeOfferChanged offerChangedEvent = GrandExchangeOfferChanged.INSTANCE;
offerChangedEvent.setOffer(internalOffer); offerChangedEvent.setOffer(internalOffer);
offerChangedEvent.setSlot(idx); offerChangedEvent.setSlot(idx);
client.getCallbacks().post(offerChangedEvent); client.getCallbacks().post(offerChangedEvent);
@@ -1061,7 +1067,7 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
public static void settingsChanged(int idx) public static void settingsChanged(int idx)
{ {
VarbitChanged varbitChanged = new VarbitChanged(); VarbitChanged varbitChanged = VarbitChanged.INSTANCE;
varbitChanged.setIndex(idx); varbitChanged.setIndex(idx);
client.getCallbacks().post(varbitChanged); client.getCallbacks().post(varbitChanged);
} }
@@ -1075,7 +1081,7 @@ public abstract class RSClientMixin implements RSClient
if (oldIsResized != isResized) if (oldIsResized != isResized)
{ {
ResizeableChanged resizeableChanged = new ResizeableChanged(); ResizeableChanged resizeableChanged = ResizeableChanged.INSTANCE;
resizeableChanged.setResized(isResized); resizeableChanged.setResized(isResized);
client.getCallbacks().post(resizeableChanged); client.getCallbacks().post(resizeableChanged);
@@ -1087,7 +1093,9 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
public static void clanMemberManagerChanged(int idx) public static void clanMemberManagerChanged(int idx)
{ {
client.getCallbacks().post(new ClanChanged(client.getClanMemberManager() != null)); ClanChanged event = ClanChanged.INSTANCE;
event.setJoined(client.getClanMemberManager() != null);
client.getCallbacks().post(event);
} }
@FieldHook("canvasWidth") @FieldHook("canvasWidth")
@@ -1271,7 +1279,7 @@ public abstract class RSClientMixin implements RSClient
@Inject @Inject
public static void onUsernameChanged(int idx) public static void onUsernameChanged(int idx)
{ {
client.getCallbacks().post(new UsernameChanged()); client.getCallbacks().post(UsernameChanged.INSTANCE);
} }
@Override @Override
@@ -1300,7 +1308,7 @@ public abstract class RSClientMixin implements RSClient
@MethodHook("openMenu") @MethodHook("openMenu")
public void menuOpened(int var1, int var2) public void menuOpened(int var1, int var2)
{ {
final MenuOpened event = new MenuOpened(); final MenuOpened event = MenuOpened.INSTANCE;
event.setMenuEntries(getMenuEntries()); event.setMenuEntries(getMenuEntries());
callbacks.post(event); callbacks.post(event);
} }
@@ -1513,7 +1521,7 @@ public abstract class RSClientMixin implements RSClient
@FieldHook("cycleCntr") @FieldHook("cycleCntr")
public static void onCycleCntrChanged(int idx) public static void onCycleCntrChanged(int idx)
{ {
client.getCallbacks().post(new ClientTick()); client.getCallbacks().post(ClientTick.INSTANCE);
} }
@Copy("shouldLeftClickOpenMenu") @Copy("shouldLeftClickOpenMenu")
@@ -1530,7 +1538,7 @@ public abstract class RSClientMixin implements RSClient
return true; return true;
} }
MenuShouldLeftClick menuShouldLeftClick = new MenuShouldLeftClick(); MenuShouldLeftClick menuShouldLeftClick = MenuShouldLeftClick.INSTANCE;
client.getCallbacks().post(menuShouldLeftClick); client.getCallbacks().post(menuShouldLeftClick);
if (menuShouldLeftClick.isForceRightClick()) if (menuShouldLeftClick.isForceRightClick())

View File

@@ -18,7 +18,8 @@ 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 = RemovedFriend.INSTANCE;
removedFriend.setName(friendName);
client.getCallbacks().post(removedFriend); client.getCallbacks().post(removedFriend);
} }
} }

View File

@@ -17,7 +17,8 @@ public abstract class RSGraphicsObjectMixin implements RSGraphicsObject
@Inject @Inject
RSGraphicsObjectMixin() RSGraphicsObjectMixin()
{ {
final GraphicsObjectCreated event = new GraphicsObjectCreated(this); final GraphicsObjectCreated event = GraphicsObjectCreated.INSTANCE;
event.setGraphicsObject(this);
client.getCallbacks().post(event); client.getCallbacks().post(event);
} }

View File

@@ -66,7 +66,12 @@ public abstract class RSGroundItemMixin implements RSGroundItem
{ {
client.getLogger().debug("Item quantity changed: {} ({} -> {})", getId(), getQuantity(), quantity); client.getLogger().debug("Item quantity changed: {} ({} -> {})", getId(), getQuantity(), quantity);
ItemQuantityChanged itemQuantityChanged = new ItemQuantityChanged(this, getTile(), getQuantity(), quantity); ItemQuantityChanged itemQuantityChanged = ItemQuantityChanged.INSTANCE;
itemQuantityChanged.setItem(this);
itemQuantityChanged.setTile(getTile());
itemQuantityChanged.setOldQuantity(getQuantity());
itemQuantityChanged.setNewQuantity(quantity);
client.getCallbacks().post(itemQuantityChanged); client.getCallbacks().post(itemQuantityChanged);
} }
} }

View File

@@ -19,7 +19,7 @@ public abstract class RSHealthBarDefinitionMixin implements RSHealthBarDefinitio
@Inject @Inject
public void onRead(RSBuffer buffer) public void onRead(RSBuffer buffer)
{ {
PostHealthBar postHealthBar = new PostHealthBar(); PostHealthBar postHealthBar = PostHealthBar.INSTANCE;
postHealthBar.setHealthBar(this); postHealthBar.setHealthBar(this);
client.getCallbacks().post(postHealthBar); client.getCallbacks().post(postHealthBar);
} }

View File

@@ -75,7 +75,8 @@ public abstract class RSItemContainerMixin implements RSItemContainer
rl$lastCycle = cycle; rl$lastCycle = cycle;
ItemContainerChanged event = new ItemContainerChanged(this); ItemContainerChanged event = ItemContainerChanged.INSTANCE;
event.setItemContainer(this);
client.getCallbacks().postDeferred(event); client.getCallbacks().postDeferred(event);
} }

View File

@@ -60,7 +60,7 @@ public abstract class RSItemDefinitionMixin implements RSItemDefinition
@MethodHook(value = "post", end = true) @MethodHook(value = "post", end = true)
public void post() public void post()
{ {
final PostItemDefinition event = new PostItemDefinition(); final PostItemDefinition event = PostItemDefinition.INSTANCE;
event.setItemDefinition(this); event.setItemDefinition(this);
client.getCallbacks().post(event); client.getCallbacks().post(event);
} }

View File

@@ -42,7 +42,7 @@ public abstract class RSNPCDefinitionMixin implements RSNPCDefinition
@Inject @Inject
public void actionsHook(int idx) public void actionsHook(int idx)
{ {
NpcActionChanged npcActionChanged = new NpcActionChanged(); NpcActionChanged npcActionChanged = NpcActionChanged.INSTANCE;
npcActionChanged.setNpcDefinition(this); npcActionChanged.setNpcDefinition(this);
npcActionChanged.setIdx(idx); npcActionChanged.setIdx(idx);
client.getCallbacks().post(npcActionChanged); client.getCallbacks().post(npcActionChanged);

View File

@@ -109,7 +109,9 @@ public abstract class RSNPCMixin implements RSNPC
{ {
if (composition == null) if (composition == null)
{ {
client.getCallbacks().post(new NpcDespawned(this)); NpcDespawned event = NpcDespawned.INSTANCE;
event.setNpc(this);
client.getCallbacks().post(event);
} }
} }

View File

@@ -46,7 +46,7 @@ public abstract class RSProjectileMixin implements RSProjectile
@Inject @Inject
RSProjectileMixin() RSProjectileMixin()
{ {
final ProjectileSpawned projectileSpawned = new ProjectileSpawned(); final ProjectileSpawned projectileSpawned = ProjectileSpawned.INSTANCE;
projectileSpawned.setProjectile(this); projectileSpawned.setProjectile(this);
client.getCallbacks().post(projectileSpawned); client.getCallbacks().post(projectileSpawned);
} }
@@ -105,7 +105,7 @@ public abstract class RSProjectileMixin implements RSProjectile
public void projectileMoved(int targetX, int targetY, int targetZ, int cycle) public void projectileMoved(int targetX, int targetY, int targetZ, int cycle)
{ {
final LocalPoint position = new LocalPoint(targetX, targetY); final LocalPoint position = new LocalPoint(targetX, targetY);
final ProjectileMoved projectileMoved = new ProjectileMoved(); final ProjectileMoved projectileMoved = ProjectileMoved.INSTANCE;
projectileMoved.setProjectile(this); projectileMoved.setProjectile(this);
projectileMoved.setPosition(position); projectileMoved.setPosition(position);
projectileMoved.setZ(targetZ); projectileMoved.setZ(targetZ);

View File

@@ -126,21 +126,21 @@ public abstract class RSTileMixin implements RSTile
if (current == null && previous != null) if (current == null && previous != null)
{ {
WallObjectDespawned wallObjectDespawned = new WallObjectDespawned(); WallObjectDespawned wallObjectDespawned = WallObjectDespawned.INSTANCE;
wallObjectDespawned.setTile(this); wallObjectDespawned.setTile(this);
wallObjectDespawned.setWallObject(previous); wallObjectDespawned.setWallObject(previous);
client.getCallbacks().post(wallObjectDespawned); client.getCallbacks().post(wallObjectDespawned);
} }
else if (current != null && previous == null) else if (current != null && previous == null)
{ {
WallObjectSpawned wallObjectSpawned = new WallObjectSpawned(); WallObjectSpawned wallObjectSpawned = WallObjectSpawned.INSTANCE;
wallObjectSpawned.setTile(this); wallObjectSpawned.setTile(this);
wallObjectSpawned.setWallObject(current); wallObjectSpawned.setWallObject(current);
client.getCallbacks().post(wallObjectSpawned); client.getCallbacks().post(wallObjectSpawned);
} }
else if (current != null) else if (current != null)
{ {
WallObjectChanged wallObjectChanged = new WallObjectChanged(); WallObjectChanged wallObjectChanged = WallObjectChanged.INSTANCE;
wallObjectChanged.setTile(this); wallObjectChanged.setTile(this);
wallObjectChanged.setPrevious(previous); wallObjectChanged.setPrevious(previous);
wallObjectChanged.setWallObject(current); wallObjectChanged.setWallObject(current);
@@ -159,21 +159,21 @@ public abstract class RSTileMixin implements RSTile
if (current == null && previous != null) if (current == null && previous != null)
{ {
DecorativeObjectDespawned decorativeObjectDespawned = new DecorativeObjectDespawned(); DecorativeObjectDespawned decorativeObjectDespawned = DecorativeObjectDespawned.INSTANCE;
decorativeObjectDespawned.setTile(this); decorativeObjectDespawned.setTile(this);
decorativeObjectDespawned.setDecorativeObject(previous); decorativeObjectDespawned.setDecorativeObject(previous);
client.getCallbacks().post(decorativeObjectDespawned); client.getCallbacks().post(decorativeObjectDespawned);
} }
else if (current != null && previous == null) else if (current != null && previous == null)
{ {
DecorativeObjectSpawned decorativeObjectSpawned = new DecorativeObjectSpawned(); DecorativeObjectSpawned decorativeObjectSpawned = DecorativeObjectSpawned.INSTANCE;
decorativeObjectSpawned.setTile(this); decorativeObjectSpawned.setTile(this);
decorativeObjectSpawned.setDecorativeObject(current); decorativeObjectSpawned.setDecorativeObject(current);
client.getCallbacks().post(decorativeObjectSpawned); client.getCallbacks().post(decorativeObjectSpawned);
} }
else if (current != null) else if (current != null)
{ {
DecorativeObjectChanged decorativeObjectChanged = new DecorativeObjectChanged(); DecorativeObjectChanged decorativeObjectChanged = DecorativeObjectChanged.INSTANCE;
decorativeObjectChanged.setTile(this); decorativeObjectChanged.setTile(this);
decorativeObjectChanged.setPrevious(previous); decorativeObjectChanged.setPrevious(previous);
decorativeObjectChanged.setDecorativeObject(current); decorativeObjectChanged.setDecorativeObject(current);
@@ -192,21 +192,21 @@ public abstract class RSTileMixin implements RSTile
if (current == null && previous != null) if (current == null && previous != null)
{ {
GroundObjectDespawned groundObjectDespawned = new GroundObjectDespawned(); GroundObjectDespawned groundObjectDespawned = GroundObjectDespawned.INSTANCE;
groundObjectDespawned.setTile(this); groundObjectDespawned.setTile(this);
groundObjectDespawned.setGroundObject(previous); groundObjectDespawned.setGroundObject(previous);
client.getCallbacks().post(groundObjectDespawned); client.getCallbacks().post(groundObjectDespawned);
} }
else if (current != null && previous == null) else if (current != null && previous == null)
{ {
GroundObjectSpawned groundObjectSpawned = new GroundObjectSpawned(); GroundObjectSpawned groundObjectSpawned = GroundObjectSpawned.INSTANCE;
groundObjectSpawned.setTile(this); groundObjectSpawned.setTile(this);
groundObjectSpawned.setGroundObject(current); groundObjectSpawned.setGroundObject(current);
client.getCallbacks().post(groundObjectSpawned); client.getCallbacks().post(groundObjectSpawned);
} }
else if (current != null) else if (current != null)
{ {
GroundObjectChanged groundObjectChanged = new GroundObjectChanged(); GroundObjectChanged groundObjectChanged = GroundObjectChanged.INSTANCE;
groundObjectChanged.setTile(this); groundObjectChanged.setTile(this);
groundObjectChanged.setPrevious(previous); groundObjectChanged.setPrevious(previous);
groundObjectChanged.setGroundObject(current); groundObjectChanged.setGroundObject(current);
@@ -282,7 +282,7 @@ public abstract class RSTileMixin implements RSTile
logger.trace("Game object despawn: {}", previous.getId()); logger.trace("Game object despawn: {}", previous.getId());
GameObjectDespawned gameObjectDespawned = new GameObjectDespawned(); GameObjectDespawned gameObjectDespawned = GameObjectDespawned.INSTANCE;
gameObjectDespawned.setTile(this); gameObjectDespawned.setTile(this);
gameObjectDespawned.setGameObject(previous); gameObjectDespawned.setGameObject(previous);
client.getCallbacks().post(gameObjectDespawned); client.getCallbacks().post(gameObjectDespawned);
@@ -296,7 +296,7 @@ public abstract class RSTileMixin implements RSTile
logger.trace("Game object spawn: {}", current.getId()); logger.trace("Game object spawn: {}", current.getId());
GameObjectSpawned gameObjectSpawned = new GameObjectSpawned(); GameObjectSpawned gameObjectSpawned = GameObjectSpawned.INSTANCE;
gameObjectSpawned.setTile(this); gameObjectSpawned.setTile(this);
gameObjectSpawned.setGameObject(current); gameObjectSpawned.setGameObject(current);
client.getCallbacks().post(gameObjectSpawned); client.getCallbacks().post(gameObjectSpawned);
@@ -310,7 +310,7 @@ public abstract class RSTileMixin implements RSTile
logger.trace("Game object change: {} -> {}", previous.getId(), current.getId()); logger.trace("Game object change: {} -> {}", previous.getId(), current.getId());
GameObjectChanged gameObjectsChanged = new GameObjectChanged(); GameObjectChanged gameObjectsChanged = GameObjectChanged.INSTANCE;
gameObjectsChanged.setTile(this); gameObjectsChanged.setTile(this);
gameObjectsChanged.setPrevious(previous); gameObjectsChanged.setPrevious(previous);
gameObjectsChanged.setGameObject(current); gameObjectsChanged.setGameObject(current);
@@ -339,7 +339,9 @@ public abstract class RSTileMixin implements RSTile
for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext()) for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext())
{ {
RSGroundItem item = (RSGroundItem) cur; RSGroundItem item = (RSGroundItem) cur;
ItemDespawned itemDespawned = new ItemDespawned(this, item); ItemDespawned itemDespawned = ItemDespawned.INSTANCE;
itemDespawned.setTile(this);
itemDespawned.setItem(item);
client.getCallbacks().post(itemDespawned); client.getCallbacks().post(itemDespawned);
} }
} }
@@ -357,7 +359,9 @@ public abstract class RSTileMixin implements RSTile
{ {
if (lastUnlink != null) if (lastUnlink != null)
{ {
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink); ItemDespawned itemDespawned = ItemDespawned.INSTANCE;
itemDespawned.setTile(this);
itemDespawned.setItem(lastUnlink);
client.getCallbacks().post(itemDespawned); client.getCallbacks().post(itemDespawned);
} }
return; return;
@@ -369,7 +373,9 @@ public abstract class RSTileMixin implements RSTile
{ {
if (lastUnlink != null) if (lastUnlink != null)
{ {
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink); ItemDespawned itemDespawned = ItemDespawned.INSTANCE;
itemDespawned.setTile(this);
itemDespawned.setItem(lastUnlink);
client.getCallbacks().post(itemDespawned); client.getCallbacks().post(itemDespawned);
} }
return; return;
@@ -402,7 +408,9 @@ public abstract class RSTileMixin implements RSTile
if (lastUnlink != null && lastUnlink != previous && lastUnlink != next) if (lastUnlink != null && lastUnlink != previous && lastUnlink != next)
{ {
ItemDespawned itemDespawned = new ItemDespawned(this, lastUnlink); ItemDespawned itemDespawned = ItemDespawned.INSTANCE;
itemDespawned.setTile(this);
itemDespawned.setItem(lastUnlink);
client.getCallbacks().post(itemDespawned); client.getCallbacks().post(itemDespawned);
} }
@@ -417,7 +425,9 @@ public abstract class RSTileMixin implements RSTile
item.setX(x); item.setX(x);
item.setY(y); item.setY(y);
ItemSpawned itemSpawned = new ItemSpawned(this, item); ItemSpawned itemSpawned = ItemSpawned.INSTANCE;
itemSpawned.setTile(this);
itemSpawned.setItem(item);
client.getCallbacks().post(itemSpawned); client.getCallbacks().post(itemSpawned);
current = forward ? current.getNext() : current.getPrevious(); current = forward ? current.getNext() : current.getPrevious();

View File

@@ -19,13 +19,17 @@ public abstract class RSVarcsMixin implements RSVarcs
@Inject @Inject
public void onVarCIntChanged(int id, int value) public void onVarCIntChanged(int id, int value)
{ {
client.getCallbacks().post(new VarClientIntChanged(id)); VarClientIntChanged event = VarClientIntChanged.INSTANCE;
event.setIndex(id);
client.getCallbacks().post(event);
} }
@MethodHook(value = "setString", end = true) @MethodHook(value = "setString", end = true)
@Inject @Inject
public void onVarCStrChanged(int id, String value) public void onVarCStrChanged(int id, String value)
{ {
client.getCallbacks().post(new VarClientStrChanged(id)); VarClientStrChanged event = VarClientStrChanged.INSTANCE;
event.setIndex(id);
client.getCallbacks().post(event);
} }
} }

View File

@@ -408,7 +408,7 @@ public abstract class RSWidgetMixin implements RSWidget
@Override @Override
public void broadcastHidden(boolean hidden) public void broadcastHidden(boolean hidden)
{ {
WidgetHiddenChanged event = new WidgetHiddenChanged(); WidgetHiddenChanged event = WidgetHiddenChanged.INSTANCE;
event.setWidget(this); event.setWidget(this);
event.setHidden(hidden); event.setHidden(hidden);
@@ -496,7 +496,7 @@ public abstract class RSWidgetMixin implements RSWidget
client.getLogger().trace("Posting widget position changed"); client.getLogger().trace("Posting widget position changed");
WidgetPositioned widgetPositioned = new WidgetPositioned(); WidgetPositioned widgetPositioned = WidgetPositioned.INSTANCE;
client.getCallbacks().postDeferred(widgetPositioned); client.getCallbacks().postDeferred(widgetPositioned);
} }

View File

@@ -62,7 +62,8 @@ public abstract class RSWorldMixin implements RSWorld
if (worlds != null && worlds.length > 0 && worlds[worlds.length - 1] == this) if (worlds != null && worlds.length > 0 && worlds[worlds.length - 1] == this)
{ {
// this is the last world in the list. // this is the last world in the list.
WorldListLoad worldLoad = new WorldListLoad(worlds); WorldListLoad worldLoad = WorldListLoad.INSTANCE;
worldLoad.setWorlds(worlds);
client.getCallbacks().post(worldLoad); client.getCallbacks().post(worldLoad);
} }
} }

Some files were not shown because too many files have changed in this diff Show More