Revert "Wintertodt selective eventbus listening" (#1539)
This reverts commit 297cf7614a.
This commit is contained in:
@@ -37,7 +37,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import static net.runelite.api.AnimationID.*;
|
import static net.runelite.api.AnimationID.*;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import static net.runelite.api.GameState.LOADING;
|
|
||||||
import net.runelite.api.InventoryID;
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.Item;
|
import net.runelite.api.Item;
|
||||||
import net.runelite.api.ItemContainer;
|
import net.runelite.api.ItemContainer;
|
||||||
@@ -50,7 +49,6 @@ import net.runelite.api.events.AnimationChanged;
|
|||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
|
||||||
import net.runelite.api.events.ItemContainerChanged;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
@@ -116,8 +114,6 @@ public class WintertodtPlugin extends Plugin
|
|||||||
private WintertodtNotifyMode notifyCondition;
|
private WintertodtNotifyMode notifyCondition;
|
||||||
private Color damageNotificationColor;
|
private Color damageNotificationColor;
|
||||||
|
|
||||||
private boolean subscribed;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
WintertodtConfig getConfig(ConfigManager configManager)
|
WintertodtConfig getConfig(ConfigManager configManager)
|
||||||
{
|
{
|
||||||
@@ -134,15 +130,12 @@ public class WintertodtPlugin extends Plugin
|
|||||||
|
|
||||||
reset();
|
reset();
|
||||||
overlayManager.add(overlay);
|
overlayManager.add(overlay);
|
||||||
|
|
||||||
handleWintertodtRegion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception
|
protected void shutDown() throws Exception
|
||||||
{
|
{
|
||||||
eventBus.unregister(this);
|
super.shutDown();
|
||||||
eventBus.unregister("inside-wintertodt");
|
|
||||||
|
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
reset();
|
reset();
|
||||||
@@ -151,23 +144,11 @@ public class WintertodtPlugin extends Plugin
|
|||||||
private void addSubscriptions()
|
private void addSubscriptions()
|
||||||
{
|
{
|
||||||
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
||||||
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
|
eventBus.subscribe(GameTick.class, this, this::onGameTick);
|
||||||
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
|
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
|
||||||
}
|
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
|
||||||
|
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
|
||||||
private void wintertodtSubscriptions(boolean subscribe)
|
eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
|
||||||
{
|
|
||||||
if (subscribe)
|
|
||||||
{
|
|
||||||
eventBus.subscribe(GameTick.class, "inside-wintertodt", this::onGameTick);
|
|
||||||
eventBus.subscribe(ChatMessage.class, "inside-wintertodt", this::onChatMessage);
|
|
||||||
eventBus.subscribe(AnimationChanged.class, "inside-wintertodt", this::onAnimationChanged);
|
|
||||||
eventBus.subscribe(ItemContainerChanged.class, "inside-wintertodt", this::onItemContainerChanged);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
eventBus.unregister("inside-wintertodt");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onConfigChanged(ConfigChanged event)
|
private void onConfigChanged(ConfigChanged event)
|
||||||
@@ -199,24 +180,9 @@ public class WintertodtPlugin extends Plugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleWintertodtRegion()
|
private void onGameTick(GameTick gameTick)
|
||||||
{
|
{
|
||||||
if (isInWintertodtRegion())
|
if (!isInWintertodtRegion())
|
||||||
{
|
|
||||||
if (!isInWintertodt)
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
log.debug("Entered Wintertodt!");
|
|
||||||
}
|
|
||||||
isInWintertodt = true;
|
|
||||||
|
|
||||||
if (!subscribed)
|
|
||||||
{
|
|
||||||
wintertodtSubscriptions(true);
|
|
||||||
subscribed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (isInWintertodt)
|
if (isInWintertodt)
|
||||||
{
|
{
|
||||||
@@ -225,25 +191,16 @@ public class WintertodtPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
isInWintertodt = false;
|
isInWintertodt = false;
|
||||||
|
return;
|
||||||
if (subscribed)
|
|
||||||
{
|
|
||||||
wintertodtSubscriptions(false);
|
|
||||||
subscribed = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void onGameStateChanged(GameStateChanged event)
|
if (!isInWintertodt)
|
||||||
{
|
|
||||||
if (event.getGameState() == LOADING)
|
|
||||||
{
|
{
|
||||||
handleWintertodtRegion();
|
reset();
|
||||||
|
log.debug("Entered Wintertodt!");
|
||||||
}
|
}
|
||||||
}
|
isInWintertodt = true;
|
||||||
|
|
||||||
private void onGameTick(GameTick gameTick)
|
|
||||||
{
|
|
||||||
checkActionTimeout();
|
checkActionTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +252,11 @@ public class WintertodtPlugin extends Plugin
|
|||||||
|
|
||||||
private void onChatMessage(ChatMessage chatMessage)
|
private void onChatMessage(ChatMessage chatMessage)
|
||||||
{
|
{
|
||||||
|
if (!isInWintertodt)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ChatMessageType chatMessageType = chatMessage.getType();
|
ChatMessageType chatMessageType = chatMessage.getType();
|
||||||
|
|
||||||
if (chatMessageType != ChatMessageType.GAMEMESSAGE && chatMessageType != ChatMessageType.SPAM)
|
if (chatMessageType != ChatMessageType.GAMEMESSAGE && chatMessageType != ChatMessageType.SPAM)
|
||||||
@@ -433,6 +395,11 @@ public class WintertodtPlugin extends Plugin
|
|||||||
|
|
||||||
private void onAnimationChanged(final AnimationChanged event)
|
private void onAnimationChanged(final AnimationChanged event)
|
||||||
{
|
{
|
||||||
|
if (!isInWintertodt)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final Player local = client.getLocalPlayer();
|
final Player local = client.getLocalPlayer();
|
||||||
|
|
||||||
if (event.getActor() != local)
|
if (event.getActor() != local)
|
||||||
@@ -479,7 +446,7 @@ public class WintertodtPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
final ItemContainer container = event.getItemContainer();
|
final ItemContainer container = event.getItemContainer();
|
||||||
|
|
||||||
if (container != client.getItemContainer(InventoryID.INVENTORY))
|
if (!isInWintertodt || container != client.getItemContainer(InventoryID.INVENTORY))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user