raids: Fixed an uncommon ArrayOutOfBoundsException in RotationSolver (#2201)
* raids: Fix !layout command & update RaidOverlay * raids: Fixed an uncommon ArrayOutOfBoundsException in RotationSolver
This commit is contained in:
@@ -128,6 +128,25 @@ class Raid
|
||||
return Joiner.on(",").join(Arrays.stream(getAllRooms()).toArray());
|
||||
}
|
||||
|
||||
void setCombatRooms(RaidRoom[] combatRooms)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
for (Room room : layout.getRooms())
|
||||
{
|
||||
if (room == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rooms[room.getPosition()].getType() == RoomType.COMBAT)
|
||||
{
|
||||
rooms[room.getPosition()] = combatRooms[index];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String toCode()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -789,7 +789,9 @@ public class RaidsPlugin extends Plugin
|
||||
|
||||
layoutFullCode = layout.getCode();
|
||||
raid.updateLayout(layout);
|
||||
RotationSolver.solve(raid.getCombatRooms());
|
||||
RaidRoom[] rooms = raid.getCombatRooms();
|
||||
RotationSolver.solve(rooms);
|
||||
raid.setCombatRooms(rooms);
|
||||
setOverlayStatus(true);
|
||||
if (this.displayLayoutMessage)
|
||||
{
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.raids.solver;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.runelite.client.plugins.raids.RaidRoom;
|
||||
import net.runelite.client.plugins.raids.RoomType;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import static net.runelite.client.plugins.raids.RaidRoom.GUARDIANS;
|
||||
import static net.runelite.client.plugins.raids.RaidRoom.MUTTADILES;
|
||||
@@ -40,13 +40,13 @@ import static net.runelite.client.plugins.raids.RaidRoom.VESPULA;
|
||||
|
||||
public class RotationSolver
|
||||
{
|
||||
private static final List[] ROTATIONS =
|
||||
{
|
||||
Arrays.asList(TEKTON, VASA, GUARDIANS, MYSTICS, SHAMANS, MUTTADILES, VANGUARDS, VESPULA),
|
||||
Arrays.asList(TEKTON, MUTTADILES, GUARDIANS, VESPULA, SHAMANS, VASA, VANGUARDS, MYSTICS),
|
||||
Arrays.asList(VESPULA, VANGUARDS, MUTTADILES, SHAMANS, MYSTICS, GUARDIANS, VASA, TEKTON),
|
||||
Arrays.asList(MYSTICS, VANGUARDS, VASA, SHAMANS, VESPULA, GUARDIANS, MUTTADILES, TEKTON)
|
||||
};
|
||||
private static final ImmutableList<ImmutableList<RaidRoom>> ROTATIONS = ImmutableList.of
|
||||
(
|
||||
ImmutableList.of(TEKTON, VASA, GUARDIANS, MYSTICS, SHAMANS, MUTTADILES, VANGUARDS, VESPULA),
|
||||
ImmutableList.of(TEKTON, MUTTADILES, GUARDIANS, VESPULA, SHAMANS, VASA, VANGUARDS, MYSTICS),
|
||||
ImmutableList.of(VESPULA, VANGUARDS, MUTTADILES, SHAMANS, MYSTICS, GUARDIANS, VASA, TEKTON),
|
||||
ImmutableList.of(MYSTICS, VANGUARDS, VASA, SHAMANS, VESPULA, GUARDIANS, MUTTADILES, TEKTON)
|
||||
);
|
||||
|
||||
public static boolean solve(RaidRoom[] rooms)
|
||||
{
|
||||
@@ -128,9 +128,9 @@ public class RotationSolver
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rooms[i].getType() != RoomType.COMBAT || rooms[i] == UNKNOWN_COMBAT)
|
||||
if ((rooms[i].getType() != RoomType.COMBAT || rooms[i] == UNKNOWN_COMBAT))
|
||||
{
|
||||
rooms[i] = match.get((index + i) % match.size());
|
||||
rooms[i] = match.get((index + i + match.size()) % match.size());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user