Merge pull request #4413 from deathbeam/cleanup-raids-plugin

Add support for preserving raids scouter inside raid + fix checking for raids state on plugin state changes
This commit is contained in:
Tomas Slusny
2018-08-06 21:55:55 +02:00
committed by GitHub
2 changed files with 109 additions and 105 deletions

View File

@@ -77,6 +77,17 @@ public interface RaidsConfig extends Config
@ConfigItem(
position = 4,
keyName = "scoutOverlayInRaid",
name = "Show scout overlay inside raid",
description = "Keep the overlay active while inside raid"
)
default boolean scoutOverlayInRaid()
{
return false;
}
@ConfigItem(
position = 5,
keyName = "whitelistedRooms",
name = "Whitelisted rooms",
description = "Display whitelisted rooms in green on the overlay. Separate with comma (full name)"
@@ -87,7 +98,7 @@ public interface RaidsConfig extends Config
}
@ConfigItem(
position = 5,
position = 6,
keyName = "blacklistedRooms",
name = "Blacklisted rooms",
description = "Display blacklisted rooms in red on the overlay. Separate with comma (full name)"
@@ -98,7 +109,7 @@ public interface RaidsConfig extends Config
}
@ConfigItem(
position = 6,
position = 7,
keyName = "enableRotationWhitelist",
name = "Enable rotation whitelist",
description = "Enable the rotation whitelist"
@@ -109,7 +120,7 @@ public interface RaidsConfig extends Config
}
@ConfigItem(
position = 7,
position = 8,
keyName = "whitelistedRotations",
name = "Whitelisted rotations",
description = "Warn when boss rotation doesn't match a whitelisted one. Add rotations like [tekton, muttadile, guardians]"
@@ -120,7 +131,7 @@ public interface RaidsConfig extends Config
}
@ConfigItem(
position = 8,
position = 9,
keyName = "enableLayoutWhitelist",
name = "Enable layout whitelist",
description = "Enable the layout whitelist"
@@ -131,7 +142,7 @@ public interface RaidsConfig extends Config
}
@ConfigItem(
position = 9,
position = 10,
keyName = "whitelistedLayouts",
name = "Whitelisted layouts",
description = "Warn when layout doesn't match a whitelisted one. Add layouts like CFSCPPCSCF separated with comma"

View File

@@ -85,11 +85,6 @@ public class RaidsPlugin extends Plugin
private static final String SPLIT_REGEX = "\\s*,\\s*";
private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)]");
private RaidsTimer timer;
@Getter
private boolean inRaidChambers;
@Inject
private ChatMessageManager chatMessageManager;
@@ -117,20 +112,25 @@ public class RaidsPlugin extends Plugin
@Inject
private SpriteManager spriteManager;
@Getter
private final ArrayList<String> roomWhitelist = new ArrayList<>();
@Getter
private final ArrayList<String> roomBlacklist = new ArrayList<>();
@Getter
private final ArrayList<String> rotationWhitelist = new ArrayList<>();
@Getter
private final ArrayList<String> layoutWhitelist = new ArrayList<>();
@Getter
private Raid raid;
@Getter
private ArrayList<String> roomWhitelist = new ArrayList<>();
private boolean inRaidChambers;
@Getter
private ArrayList<String> roomBlacklist = new ArrayList<>();
@Getter
private ArrayList<String> rotationWhitelist = new ArrayList<>();
@Getter
private ArrayList<String> layoutWhitelist = new ArrayList<>();
private RaidsTimer timer;
@Provides
RaidsConfig provideConfig(ConfigManager configManager)
@@ -149,14 +149,8 @@ public class RaidsPlugin extends Plugin
{
overlayManager.add(overlay);
overlayManager.add(pointsOverlay);
if (client.getGameState() == GameState.LOGGED_IN)
{
inRaidChambers = client.getVar(Varbits.IN_RAID) == 1;
updateInfoBoxState();
}
updateLists();
checkRaidPresence(true);
}
@Override
@@ -164,40 +158,28 @@ public class RaidsPlugin extends Plugin
{
overlayManager.remove(overlay);
overlayManager.remove(pointsOverlay);
if (timer != null)
{
infoBoxManager.removeInfoBox(timer);
}
infoBoxManager.removeInfoBox(timer);
inRaidChambers = false;
raid = null;
timer = null;
}
@Subscribe
public void onConfigChanged(ConfigChanged event)
{
if (!event.getGroup().equals("raids"))
{
return;
}
if (event.getKey().equals("raidsTimer"))
{
updateInfoBoxState();
return;
}
if (event.getKey().equals("whitelistedRooms"))
{
updateList(roomWhitelist, config.whitelistedRooms());
}
if (event.getKey().equals("blacklistedRooms"))
{
updateList(roomBlacklist, config.blacklistedRooms());
}
if (event.getKey().equals("whitelistedRotations"))
{
updateList(rotationWhitelist, config.whitelistedRotations());
}
if (event.getKey().equals("whitelistedLayouts"))
{
updateList(layoutWhitelist, config.whitelistedLayouts());
}
updateLists();
checkRaidPresence(true);
}
@Subscribe
@@ -219,47 +201,7 @@ public class RaidsPlugin extends Plugin
@Subscribe
public void onVarbitChange(VarbitChanged event)
{
boolean setting = client.getVar(Varbits.IN_RAID) == 1;
if (inRaidChambers != setting)
{
inRaidChambers = setting;
updateInfoBoxState();
if (inRaidChambers)
{
raid = buildRaid();
if (raid == null)
{
log.debug("Failed to build raid");
return;
}
Layout layout = layoutSolver.findLayout(raid.toCode());
if (layout == null)
{
log.debug("Could not find layout match");
return;
}
raid.updateLayout(layout);
RotationSolver.solve(raid.getCombatRooms());
overlay.setScoutOverlayShown(true);
}
else if (!config.scoutOverlayAtBank())
{
overlay.setScoutOverlayShown(false);
raid = null;
}
}
if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1)
{
overlay.setScoutOverlayShown(false);
raid = null;
}
checkRaidPresence(false);
}
@Subscribe
@@ -321,23 +263,74 @@ public class RaidsPlugin extends Plugin
}
}
private void checkRaidPresence(boolean force)
{
if (client.getGameState() != GameState.LOGGED_IN)
{
return;
}
boolean setting = client.getVar(Varbits.IN_RAID) == 1;
if (force || inRaidChambers != setting)
{
inRaidChambers = setting;
updateInfoBoxState();
if (inRaidChambers)
{
raid = buildRaid();
if (raid == null)
{
log.debug("Failed to build raid");
return;
}
Layout layout = layoutSolver.findLayout(raid.toCode());
if (layout == null)
{
log.debug("Could not find layout match");
return;
}
raid.updateLayout(layout);
RotationSolver.solve(raid.getCombatRooms());
overlay.setScoutOverlayShown(true);
}
else if (!config.scoutOverlayAtBank())
{
overlay.setScoutOverlayShown(false);
}
}
// If we left party raid was started or we left raid
if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 && (!inRaidChambers || !config.scoutOverlayInRaid()))
{
overlay.setScoutOverlayShown(false);
}
}
private void updateInfoBoxState()
{
if (timer != null)
if (timer == null)
{
if (inRaidChambers && config.raidsTimer())
{
infoBoxManager.addInfoBox(timer);
}
else
{
infoBoxManager.removeInfoBox(timer);
}
return;
}
if (!inRaidChambers)
{
timer = null;
}
if (inRaidChambers && config.raidsTimer())
{
infoBoxManager.addInfoBox(timer);
}
else
{
infoBoxManager.removeInfoBox(timer);
}
if (!inRaidChambers)
{
timer = null;
}
}
@@ -372,7 +365,7 @@ public class RaidsPlugin extends Plugin
}
}
public int getRotationMatches()
int getRotationMatches()
{
String rotation = raid.getRotationString().toLowerCase();
String[] bosses = rotation.split(SPLIT_REGEX);