Merge pull request #675 from Kamielvf/raids-plugin-fix
Fix minor issues with Raids plugin
This commit is contained in:
@@ -41,14 +41,18 @@ public class Raid
|
||||
public void updateLayout(Layout layout)
|
||||
{
|
||||
if (layout == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
for (int i = 0; i < rooms.length; i++)
|
||||
{
|
||||
if (layout.getRoomAt(i) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
RaidRoom room = rooms[i];
|
||||
|
||||
@@ -58,10 +62,14 @@ public class Raid
|
||||
room = new RaidRoom(null, type);
|
||||
|
||||
if (type == RaidRoom.Type.COMBAT)
|
||||
{
|
||||
room.setBoss(RaidRoom.Boss.UNKNOWN);
|
||||
}
|
||||
|
||||
if (type == RaidRoom.Type.PUZZLE)
|
||||
{
|
||||
room.setPuzzle(RaidRoom.Puzzle.UNKNOWN);
|
||||
}
|
||||
|
||||
setRoom(room, i);
|
||||
}
|
||||
@@ -76,7 +84,9 @@ public class Raid
|
||||
public void setRoom(RaidRoom room, int position)
|
||||
{
|
||||
if (position < rooms.length)
|
||||
{
|
||||
rooms[position] = room;
|
||||
}
|
||||
}
|
||||
|
||||
public RaidRoom[] getCombatRooms()
|
||||
@@ -86,10 +96,14 @@ public class Raid
|
||||
for (Room room : layout.getRooms())
|
||||
{
|
||||
if (room == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rooms[room.getPosition()].getType() == RaidRoom.Type.COMBAT)
|
||||
{
|
||||
combatRooms.add(rooms[room.getPosition()]);
|
||||
}
|
||||
}
|
||||
|
||||
return combatRooms.toArray(new RaidRoom[combatRooms.size()]);
|
||||
@@ -102,9 +116,13 @@ public class Raid
|
||||
for (RaidRoom room : rooms)
|
||||
{
|
||||
if (room != null)
|
||||
{
|
||||
builder.append(room.getType().getCode());
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
|
||||
@@ -55,7 +55,9 @@ public class RaidRoom
|
||||
for (Type type : Type.values())
|
||||
{
|
||||
if (type.getCode().equalsIgnoreCase(String.valueOf(code)))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return Type.EMPTY;
|
||||
@@ -83,7 +85,9 @@ public class RaidRoom
|
||||
for (Boss boss : Boss.values())
|
||||
{
|
||||
if (boss.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return boss;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -107,7 +111,9 @@ public class RaidRoom
|
||||
for (Puzzle puzzle : Puzzle.values())
|
||||
{
|
||||
if (puzzle.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return puzzle;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -61,7 +61,7 @@ import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Raids Plugin"
|
||||
name = "Raids"
|
||||
)
|
||||
@Slf4j
|
||||
public class RaidsPlugin extends Plugin
|
||||
@@ -127,6 +127,11 @@ public class RaidsPlugin extends Plugin
|
||||
updateInfoBoxState();
|
||||
}
|
||||
|
||||
if (config.pointsMessage())
|
||||
{
|
||||
cacheColors();
|
||||
}
|
||||
|
||||
updateBlacklist();
|
||||
}
|
||||
|
||||
@@ -134,20 +139,28 @@ public class RaidsPlugin extends Plugin
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (config.pointsMessage())
|
||||
{
|
||||
cacheColors();
|
||||
}
|
||||
|
||||
if (event.getKey().equals("raidsTimer"))
|
||||
{
|
||||
updateInfoBoxState();
|
||||
}
|
||||
|
||||
if (event.getKey().equals("blacklistedRooms"))
|
||||
{
|
||||
updateBlacklist();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -212,7 +225,9 @@ public class RaidsPlugin extends Plugin
|
||||
if (message.startsWith(RAID_COMPLETE_MESSAGE))
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
timer.setStopped(true);
|
||||
}
|
||||
|
||||
if (config.pointsMessage())
|
||||
{
|
||||
@@ -254,19 +269,25 @@ public class RaidsPlugin extends Plugin
|
||||
if (timer != null)
|
||||
{
|
||||
if (inRaidChambers && config.raidsTimer())
|
||||
{
|
||||
infoBoxManager.addInfoBox(timer);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
}
|
||||
|
||||
if (!inRaidChambers)
|
||||
{
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBlacklist()
|
||||
{
|
||||
blacklist.clear();
|
||||
blacklist.addAll(Arrays.asList(config.blacklistedRooms().toLowerCase().split(", ")));
|
||||
blacklist.addAll(Arrays.asList(config.blacklistedRooms().toLowerCase().split("\\s*,\\s*")));
|
||||
}
|
||||
|
||||
private void cacheColors()
|
||||
@@ -287,10 +308,14 @@ public class RaidsPlugin extends Plugin
|
||||
for (int y = 0; y < SCENE_SIZE; y++)
|
||||
{
|
||||
if (tiles[x][y] == null || tiles[x][y].getWallObject() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tiles[x][y].getWallObject().getId() == ObjectID.NULL_12231)
|
||||
{
|
||||
return tiles[x][y].getRegionLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +327,9 @@ public class RaidsPlugin extends Plugin
|
||||
Point gridBase = findLobbyBase();
|
||||
|
||||
if (gridBase == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Raid raid = new Raid();
|
||||
Tile[][] tiles;
|
||||
@@ -314,9 +341,13 @@ public class RaidsPlugin extends Plugin
|
||||
tiles = client.getRegion().getTiles()[plane];
|
||||
|
||||
if (tiles[gridBase.getX() + RaidRoom.ROOM_MAX_SIZE][gridBase.getY()] == null)
|
||||
{
|
||||
position = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i > -2; i--)
|
||||
{
|
||||
@@ -328,10 +359,14 @@ public class RaidsPlugin extends Plugin
|
||||
offsetX = 0;
|
||||
|
||||
if (x > SCENE_SIZE && position > 1 && position < 4)
|
||||
{
|
||||
position++;
|
||||
}
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
offsetX = Math.abs(x) + 1; //add 1 because the tile at x=0 will always be null
|
||||
}
|
||||
|
||||
if (x < SCENE_SIZE && y >= 0 && y < SCENE_SIZE)
|
||||
{
|
||||
@@ -347,7 +382,9 @@ public class RaidsPlugin extends Plugin
|
||||
}
|
||||
|
||||
if (position == 0 && startX != j)
|
||||
{
|
||||
startX = j;
|
||||
}
|
||||
|
||||
Tile base = tiles[offsetX > 0 ? 1 : x][y];
|
||||
RaidRoom room = determineRoom(base);
|
||||
@@ -368,7 +405,9 @@ public class RaidsPlugin extends Plugin
|
||||
InstanceTemplates template = InstanceTemplates.findMatch(chunkData);
|
||||
|
||||
if (template == null)
|
||||
{
|
||||
return room;
|
||||
}
|
||||
|
||||
switch (template)
|
||||
{
|
||||
@@ -458,7 +497,9 @@ public class RaidsPlugin extends Plugin
|
||||
private BufferedImage getRaidsIcon()
|
||||
{
|
||||
if (raidsIcon != null)
|
||||
{
|
||||
return raidsIcon;
|
||||
}
|
||||
|
||||
InputStream in = RaidsPlugin.class.getResourceAsStream("raids_icon.png");
|
||||
|
||||
|
||||
@@ -52,7 +52,9 @@ public class RaidsTimer extends InfoBox
|
||||
public String getText()
|
||||
{
|
||||
if (startTime == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!stopped)
|
||||
{
|
||||
@@ -61,7 +63,9 @@ public class RaidsTimer extends InfoBox
|
||||
}
|
||||
|
||||
if (time.getHour() > 0)
|
||||
{
|
||||
return time.format(DateTimeFormatter.ofPattern("HH:mm"));
|
||||
}
|
||||
|
||||
return time.format(DateTimeFormatter.ofPattern("mm:ss"));
|
||||
}
|
||||
@@ -70,7 +74,9 @@ public class RaidsTimer extends InfoBox
|
||||
public Color getTextColor()
|
||||
{
|
||||
if (stopped)
|
||||
{
|
||||
return Color.GREEN;
|
||||
}
|
||||
|
||||
return Color.WHITE;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,9 @@ public class Layout
|
||||
for (Room room : rooms)
|
||||
{
|
||||
if (room.getPosition() == position)
|
||||
{
|
||||
return room;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -119,9 +119,11 @@ public class LayoutSolver
|
||||
}
|
||||
|
||||
if (matches == 1)
|
||||
{
|
||||
return solution;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int calcStart(String directions)
|
||||
@@ -173,7 +175,9 @@ public class LayoutSolver
|
||||
Matcher match = regex.matcher(code);
|
||||
|
||||
if (!match.find())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String symbols, directions;
|
||||
int position = calcStart(match.group(3));
|
||||
|
||||
@@ -43,7 +43,9 @@ public class RotationSolver
|
||||
public E get(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
index = index + size();
|
||||
}
|
||||
|
||||
return super.get(index % size());
|
||||
}
|
||||
@@ -59,8 +61,10 @@ public class RotationSolver
|
||||
|
||||
public static boolean solve(RaidRoom[] rooms)
|
||||
{
|
||||
if (rooms == null)
|
||||
if (rooms == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Rotation<Boss> match = null;
|
||||
Integer start = null;
|
||||
@@ -70,19 +74,27 @@ public class RotationSolver
|
||||
for (int i = 0; i < rooms.length; i++)
|
||||
{
|
||||
if (rooms[i] == null || rooms[i].getBoss() == null || rooms[i].getBoss() == Boss.UNKNOWN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (start == null)
|
||||
{
|
||||
start = i;
|
||||
}
|
||||
|
||||
known++;
|
||||
}
|
||||
|
||||
if (known < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (known == rooms.length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Rotation rotation : ROTATIONS)
|
||||
{
|
||||
@@ -94,14 +106,20 @@ public class RotationSolver
|
||||
for (int j = start + 1; j < rooms.length; j++)
|
||||
{
|
||||
if (rooms[j].getBoss() == null || rooms[j].getBoss() == Boss.UNKNOWN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rooms[j].getBoss() != rotation.get(i + j - start))
|
||||
{
|
||||
break COMPARE;
|
||||
}
|
||||
}
|
||||
|
||||
if (match != null && match != rotation)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
index = i - start;
|
||||
match = rotation;
|
||||
@@ -110,15 +128,21 @@ public class RotationSolver
|
||||
}
|
||||
|
||||
if (match == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rooms.length; i++)
|
||||
{
|
||||
if (rooms[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rooms[i].getBoss() == null || rooms[i].getBoss() == Boss.UNKNOWN)
|
||||
{
|
||||
rooms[i].setBoss(match.get(index + i));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user