The eventbus handles the casting now -> use method reference

This commit is contained in:
Owain van Brakel
2019-07-14 04:14:19 +02:00
parent c9cdab9df5
commit d08a7775fa
22 changed files with 82 additions and 89 deletions

View File

@@ -68,7 +68,7 @@ public class SessionManager
this.eventBus = eventBus;
this.wsClient = wsClient;
this.eventBus.subscribe(LoginResponse.class, this, o -> this.onLoginResponse((LoginResponse) o));
this.eventBus.subscribe(LoginResponse.class, this, this::onLoginResponse);
}
public void loadSession()

View File

@@ -55,7 +55,7 @@ public class ChatCommandManager implements ChatboxInputListener
// eventBus.register(this);
commandManager.register(this);
eventBus.subscribe(ChatMessage.class, this, o -> this.onChatMessage((ChatMessage) o));
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
}
public void registerCommand(String command, BiConsumer<ChatMessage, String> execute)

View File

@@ -79,11 +79,11 @@ public class ChatMessageManager
this.chatColorConfig = chatColorConfig;
this.clientThread = clientThread;
eventbus.subscribe(VarbitChanged.class, this, o -> this.onVarbitChanged((VarbitChanged) o));
eventbus.subscribe(ResizeableChanged.class, this, o -> this.onResizeableChanged((ResizeableChanged) o));
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(ChatMessage.class, this, o -> this.onChatMessage((ChatMessage) o));
eventbus.subscribe(ScriptCallbackEvent.class, this, o -> this.onScriptCallbackEvent((ScriptCallbackEvent) o));
eventbus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
eventbus.subscribe(ResizeableChanged.class, this, this::onResizeableChanged);
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventbus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
}
private void onVarbitChanged(VarbitChanged event)

View File

@@ -67,7 +67,7 @@ public class CommandManager
this.eventBus = eventBus;
this.clientThread = clientThread;
eventBus.subscribe(ScriptCallbackEvent.class, this, o -> this.onScriptCallbackEvent((ScriptCallbackEvent) o));
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
}
public void register(ChatboxInputListener chatboxInputListener)

View File

@@ -106,8 +106,8 @@ public class ClanManager
this.client = client;
this.spriteManager = spriteManager;
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(ClanChanged.class, this, o -> this.onClanChanged((ClanChanged) o));
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(ClanChanged.class, this, this::onClanChanged);
}
public ClanMemberRank getRank(String playerName)

View File

@@ -316,8 +316,8 @@ public class ItemManager
});
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(PostItemDefinition.class, this, o -> this.onPostItemDefinition((PostItemDefinition) o));
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(PostItemDefinition.class, this, this::onPostItemDefinition);
}
private void loadPrices()

View File

@@ -81,13 +81,13 @@ public class LootManager
this.eventBus = eventBus;
this.client = client;
eventBus.subscribe(GameTick.class, this, o -> this.onGameTick((GameTick) o));
eventBus.subscribe(NpcDespawned.class, this, o -> this.onNpcDespawned((NpcDespawned) o));
eventBus.subscribe(PlayerDespawned.class, this, o -> this.onPlayerDespawned((PlayerDespawned) o));
eventBus.subscribe(ItemSpawned.class, this, o -> this.onItemSpawned((ItemSpawned) o));
eventBus.subscribe(ItemDespawned.class, this, o -> this.onItemDespawned((ItemDespawned) o));
eventBus.subscribe(ItemQuantityChanged.class, this, o -> this.onItemQuantityChanged((ItemQuantityChanged) o));
eventBus.subscribe(AnimationChanged.class, this, o -> this.onAnimationChanged((AnimationChanged) o));
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned);
eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned);
eventBus.subscribe(ItemDespawned.class, this, this::onItemDespawned);
eventBus.subscribe(ItemQuantityChanged.class, this, this::onItemQuantityChanged);
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
}
private void onNpcDespawned(NpcDespawned npcDespawned)

View File

@@ -80,8 +80,8 @@ public class ChatboxPanelManager
this.chatboxTextInputProvider = chatboxTextInputProvider;
eventBus.subscribe(ScriptCallbackEvent.class, this, o -> this.onScriptCallbackEvent((ScriptCallbackEvent) o));
eventBus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
}
public void close()

View File

@@ -107,13 +107,13 @@ public class MenuManager
this.eventBus = eventBus;
eventBus.subscribe(MenuOpened.class, this, o -> this.onMenuOpened((MenuOpened) o));
eventBus.subscribe(MenuEntryAdded.class, this, o -> this.onMenuEntryAdded((MenuEntryAdded) o));
eventBus.subscribe(BeforeRender.class, this, o -> this.onBeforeRender((BeforeRender) o));
eventBus.subscribe(PlayerMenuOptionsChanged.class, this, o -> this.onPlayerMenuOptionsChanged((PlayerMenuOptionsChanged) o));
eventBus.subscribe(NpcActionChanged.class, this, o -> this.onNpcActionChanged((NpcActionChanged) o));
eventBus.subscribe(WidgetPressed.class, this, o -> this.onWidgetPressed((WidgetPressed) o));
eventBus.subscribe(MenuOptionClicked.class, this, o -> this.onMenuOptionClicked((MenuOptionClicked) o));
eventBus.subscribe(MenuOpened.class, this, this::onMenuOpened);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(BeforeRender.class, this, this::onBeforeRender);
eventBus.subscribe(PlayerMenuOptionsChanged.class, this, this::onPlayerMenuOptionsChanged);
eventBus.subscribe(NpcActionChanged.class, this, this::onNpcActionChanged);
eventBus.subscribe(WidgetPressed.class, this, this::onWidgetPressed);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
}
/**

View File

@@ -119,8 +119,8 @@ public class PluginManager
this.executor = executor;
this.sceneTileManager = sceneTileManager;
eventBus.subscribe(SessionOpen.class, this, o -> this.onSessionOpen((SessionOpen) o));
eventBus.subscribe(SessionClose.class, this, o -> this.onSessionClose((SessionClose) o));
eventBus.subscribe(SessionOpen.class, this, this::onSessionOpen);
eventBus.subscribe(SessionClose.class, this, this::onSessionClose);
}
public void watch()

View File

@@ -191,12 +191,12 @@ public class AoeWarningPlugin extends Plugin
private void addSubscriptions()
{
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(ProjectileMoved.class, this, o -> this.onProjectileMoved((ProjectileMoved) o));
eventbus.subscribe(GameObjectSpawned.class, this, o -> this.onGameObjectSpawned((GameObjectSpawned) o));
eventbus.subscribe(GameObjectDespawned.class, this, o -> this.onGameObjectDespawned((GameObjectDespawned) o));
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(GameTick.class, this, o -> this.onGameTick((GameTick) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventbus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onConfigChanged(ConfigChanged event)

View File

@@ -175,12 +175,12 @@ public class CannonPlugin extends Plugin
private void addSubscriptions()
{
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(ItemContainerChanged.class, this, o -> this.onItemContainerChanged((ItemContainerChanged) o));
eventbus.subscribe(GameObjectSpawned.class, this, o -> this.onGameObjectSpawned((GameObjectSpawned) o));
eventbus.subscribe(ProjectileMoved.class, this, o -> this.onProjectileMoved((ProjectileMoved) o));
eventbus.subscribe(ChatMessage.class, this, o -> this.onChatMessage((ChatMessage) o));
eventbus.subscribe(GameTick.class, this, o -> this.onGameTick((GameTick) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventbus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventbus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventbus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onItemContainerChanged(ItemContainerChanged event)

View File

@@ -357,20 +357,14 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
log.error("error stopping plugin", ex);
}
try
{
shutDown();
}
catch (Exception ex)
{
}
shutDown();
}
});
}
@Override
protected void shutDown() throws Exception
protected void shutDown()
{
super.shutDown();
@@ -445,9 +439,8 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
private void addSubscriptions()
{
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
}
@Provides

View File

@@ -85,7 +85,7 @@ public class InfoPlugin extends Plugin
private void addSubscriptions()
{
eventbus.subscribe(SessionOpen.class, this, o -> panel.onSessionOpen((SessionOpen) o));
eventbus.subscribe(SessionClose.class, this, o -> panel.onSessionClose((SessionClose) o));
eventbus.subscribe(SessionOpen.class, this, event -> panel.onSessionOpen(event));
eventbus.subscribe(SessionClose.class, this, event -> panel.onSessionClose(event));
}
}

View File

@@ -242,16 +242,16 @@ public class NpcIndicatorsPlugin extends Plugin
private void addSubscriptions()
{
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(FocusChanged.class, this, o -> this.onFocusChanged((FocusChanged) o));
eventbus.subscribe(MenuEntryAdded.class, this, o -> this.onMenuEntryAdded((MenuEntryAdded) o));
eventbus.subscribe(MenuOptionClicked.class, this, o -> this.onMenuOptionClicked((MenuOptionClicked) o));
eventbus.subscribe(NpcSpawned.class, this, o -> this.onNpcSpawned((NpcSpawned) o));
eventbus.subscribe(NpcDefinitionChanged.class, this, o -> this.onNpcDefinitionChanged((NpcDefinitionChanged) o));
eventbus.subscribe(NpcDespawned.class, this, o -> this.onNpcDespawned((NpcDespawned) o));
eventbus.subscribe(GraphicsObjectCreated.class, this, o -> this.onGraphicsObjectCreated((GraphicsObjectCreated) o));
eventbus.subscribe(GameTick.class, this, o -> this.onGameTick((GameTick) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(FocusChanged.class, this, this::onFocusChanged);
eventbus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventbus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
eventbus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventbus.subscribe(NpcDefinitionChanged.class, this, this::onNpcDefinitionChanged);
eventbus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventbus.subscribe(GraphicsObjectCreated.class, this, this::onGraphicsObjectCreated);
eventbus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onGameStateChanged(GameStateChanged event)

View File

@@ -150,15 +150,15 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener
private void addSubscriptions()
{
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(FocusChanged.class, this, o -> this.onFocusChanged((FocusChanged) o));
eventbus.subscribe(GameObjectSpawned.class, this, o -> this.onGameObjectSpawned((GameObjectSpawned) o));
eventbus.subscribe(DecorativeObjectSpawned.class, this, o -> this.onDecorativeObjectSpawned((DecorativeObjectSpawned) o));
eventbus.subscribe(GameObjectDespawned.class, this, o -> this.onGameObjectDespawned((GameObjectDespawned) o));
eventbus.subscribe(DecorativeObjectDespawned.class, this, o -> this.onDecorativeObjectDespawned((DecorativeObjectDespawned) o));
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(MenuOptionClicked.class, this, o -> this.onMenuOptionClicked((MenuOptionClicked) o));
eventbus.subscribe(MenuEntryAdded.class, this, o -> this.onMenuEntryAdded((MenuEntryAdded) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(FocusChanged.class, this, this::onFocusChanged);
eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventbus.subscribe(DecorativeObjectSpawned.class, this, this::onDecorativeObjectSpawned);
eventbus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventbus.subscribe(DecorativeObjectDespawned.class, this, this::onDecorativeObjectDespawned);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
eventbus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
}
@Override

View File

@@ -179,8 +179,8 @@ public class RuneLitePlusPlugin extends Plugin
private void addSubscriptions()
{
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(ScriptCallbackEvent.class, this, o -> this.onScriptCallbackEvent((ScriptCallbackEvent) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
}
private void onScriptCallbackEvent(ScriptCallbackEvent e)

View File

@@ -169,10 +169,10 @@ public class ClientUI
this.configManager = configManager;
this.clientThreadProvider = clientThreadProvider;
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(NavigationButtonAdded.class, this, o -> this.onNavigationButtonAdded((NavigationButtonAdded) o));
eventbus.subscribe(NavigationButtonRemoved.class, this, o -> this.onNavigationButtonRemoved((NavigationButtonRemoved) o));
eventbus.subscribe(GameStateChanged.class, this, o -> this.onGameStateChanged((GameStateChanged) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(NavigationButtonAdded.class, this, this::onNavigationButtonAdded);
eventbus.subscribe(NavigationButtonRemoved.class, this, this::onNavigationButtonRemoved);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
}
private void onConfigChanged(ConfigChanged event)

View File

@@ -111,8 +111,8 @@ public class OverlayManager
this.configManager = configManager;
this.eventBus = eventBus;
eventBus.subscribe(PluginChanged.class, this, o -> this.onPluginChanged((PluginChanged) o));
eventBus.subscribe(MenuOptionClicked.class, this, o -> this.onMenuOptionClicked((MenuOptionClicked) o));
eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
}
private void onPluginChanged(final PluginChanged event)

View File

@@ -111,10 +111,10 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
keyManager.registerKeyListener(this);
mouseManager.registerMouseListener(this);
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(FocusChanged.class, this, o -> this.onFocusChanged((FocusChanged) o));
eventbus.subscribe(ClientTick.class, this, o -> this.onClientTick((ClientTick) o));
eventbus.subscribe(BeforeRender.class, this, o -> this.onBeforeRender((BeforeRender) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(FocusChanged.class, this, this::onFocusChanged);
eventbus.subscribe(ClientTick.class, this, this::onClientTick);
eventbus.subscribe(BeforeRender.class, this, this::onBeforeRender);
}
private void updateConfig()

View File

@@ -54,7 +54,7 @@ public class InfoBoxManager
{
this.runeLiteConfig = runeLiteConfig;
eventbus.subscribe(ConfigChanged.class, this, o -> this.onConfigChanged((ConfigChanged) o));
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
}
private void onConfigChanged(ConfigChanged event)

View File

@@ -70,8 +70,8 @@ public class PartyService
this.sessionManager = sessionManager;
this.eventBus = eventBus;
eventBus.subscribe(UserJoin.class, this, o -> this.onUserJoin((UserJoin) o));
eventBus.subscribe(UserPart.class, this, o -> this.onUserPart((UserPart) o));
eventBus.subscribe(UserJoin.class, this, this::onUserJoin);
eventBus.subscribe(UserPart.class, this, this::onUserPart);
}
public void changeParty(UUID newParty)