Properly check for changing values in raids plugin
- Determine if we are in raid on startup - Properly reset state on shutdown - Do not reset raid state when not necessary Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -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,73 @@ 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 (client.getVar(VarPlayer.IN_RAID_PARTY) == -1)
|
||||
{
|
||||
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 +364,7 @@ public class RaidsPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
public int getRotationMatches()
|
||||
int getRotationMatches()
|
||||
{
|
||||
String rotation = raid.getRotationString().toLowerCase();
|
||||
String[] bosses = rotation.split(SPLIT_REGEX);
|
||||
|
||||
Reference in New Issue
Block a user