Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tomb: death check for cursed phalanx detector #101

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.duckblade.osrs.toa.util.InventoryUtil;
import com.duckblade.osrs.toa.util.RaidRoom;
import com.duckblade.osrs.toa.util.RaidState;
import com.duckblade.osrs.toa.util.RaidStateTracker;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
import javax.inject.Inject;
Expand All @@ -16,6 +17,7 @@
import net.runelite.api.ItemID;
import net.runelite.api.MenuEntry;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.MenuOptionClicked;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
Expand All @@ -29,18 +31,23 @@ public class CursedPhalanxDetector implements PluginLifecycleComponent
ItemID.OSMUMTENS_FANG_OR
);

private boolean isEligibleForKit = true;

private final EventBus eventBus;
private final Client client;
private final RaidStateTracker raidStateTracker;

@Override
public boolean isEnabled(final TombsOfAmascutConfig config, final RaidState raidState)
{
return raidState.getCurrentRoom() == RaidRoom.TOMB && config.cursedPhalanxDetect();
return raidState.isInRaid() &&
config.cursedPhalanxDetect();
}

@Override
public void startUp()
{
isEligibleForKit = true;
eventBus.register(this);
}

Expand All @@ -50,16 +57,31 @@ public void shutDown()
eventBus.unregister(this);
}

@Subscribe
private void onChatMessage(ChatMessage e)
{
if (e.getType() != ChatMessageType.GAMEMESSAGE || !isEligibleForKit)
{
return;
}

if (e.getMessage().contains("Total deaths"))
{
isEligibleForKit = false;
}
}

@Subscribe
private void onMenuOptionClicked(final MenuOptionClicked event)
{
if (client.getVarbitValue(Varbits.TOA_RAID_LEVEL) < 500)
if (!isEligibleForKit ||
raidStateTracker.getCurrentState().getCurrentRoom() != RaidRoom.TOMB ||
client.getVarbitValue(Varbits.TOA_RAID_LEVEL) < 500)
{
return;
}

final MenuEntry menuEntry = event.getMenuEntry();

if (!menuEntry.getOption().equals("Open"))
{
return;
Expand Down
Loading