Add Crab Handlers and clean up Scouter.

This commit is contained in:
Ganom
2019-06-18 16:45:29 -04:00
parent 3780e8ccd4
commit dd3c7650d8
13 changed files with 359 additions and 299 deletions

View File

@@ -40,7 +40,7 @@ public class Raid
@Getter @Getter
private Layout layout; private Layout layout;
public void updateLayout(Layout layout) void updateLayout(Layout layout)
{ {
if (layout == null) if (layout == null)
{ {
@@ -83,7 +83,7 @@ public class Raid
return rooms[position]; return rooms[position];
} }
public void setRoom(RaidRoom room, int position) void setRoom(RaidRoom room, int position)
{ {
if (position < rooms.length) if (position < rooms.length)
{ {
@@ -91,7 +91,7 @@ public class Raid
} }
} }
public RaidRoom[] getCombatRooms() RaidRoom[] getCombatRooms()
{ {
List<RaidRoom> combatRooms = new ArrayList<>(); List<RaidRoom> combatRooms = new ArrayList<>();
@@ -111,12 +111,34 @@ public class Raid
return combatRooms.toArray(new RaidRoom[combatRooms.size()]); return combatRooms.toArray(new RaidRoom[combatRooms.size()]);
} }
public String getRotationString() String getRotationString()
{ {
return Joiner.on(",").join(Arrays.stream(getCombatRooms()).map(r -> r.getBoss().getName()).toArray()); return Joiner.on(",").join(Arrays.stream(getCombatRooms()).map(r -> r.getBoss().getName()).toArray());
} }
public String toCode() private RaidRoom[] getAllRooms()
{
List<RaidRoom> getAllRooms = new ArrayList<>();
for (Room room : layout.getRooms())
{
if (room == null)
{
continue;
}
getAllRooms.add(rooms[room.getPosition()]);
}
return getAllRooms.toArray(new RaidRoom[0]);
}
String getFullRotationString()
{
return Joiner.on(",").join(Arrays.stream(getAllRooms()).toArray());
}
String toCode()
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@@ -135,7 +157,7 @@ public class Raid
return builder.toString(); return builder.toString();
} }
public String toRoomString() String toRoomString()
{ {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View File

@@ -31,7 +31,46 @@ import net.runelite.api.Tile;
public class RaidRoom public class RaidRoom
{ {
public static final int ROOM_MAX_SIZE = 32; static final int ROOM_MAX_SIZE = 32;
@Getter
private final Tile base;
@Getter
@Setter
private Type type;
@Getter
@Setter
private Boss boss;
@Getter
@Setter
private Puzzle puzzle;
@Getter
@Setter
private RaidRoom previousRoom;
@Getter
@Setter
private RaidRoom nextRoom;
RaidRoom(Tile base, Type type)
{
this.base = base;
this.type = type;
}
@Override
public String toString()
{
switch (type)
{
case COMBAT:
return " " + type.getName() + " - " + boss.getName();
case PUZZLE:
return " " + type.getName() + " - " + puzzle.getName();
default:
return " " + type.getName();
}
}
@AllArgsConstructor @AllArgsConstructor
public enum Type public enum Type
@@ -119,49 +158,4 @@ public class RaidRoom
return null; return null;
} }
} }
@Getter
private final Tile base;
@Getter
@Setter
private Type type;
@Getter
@Setter
private Boss boss;
@Getter
@Setter
private Puzzle puzzle;
@Getter
@Setter
private RaidRoom previousRoom;
@Getter
@Setter
private RaidRoom nextRoom;
public RaidRoom(Tile base, Type type)
{
this.base = base;
this.type = type;
}
@Override
public String toString()
{
switch (type)
{
case COMBAT:
return "RaidRoom (type: " + type.getName() + ", " + boss.getName() + ")";
case PUZZLE:
return "RaidRoom (type: " + type.getName() + ", " + puzzle.getName() + ")";
default:
return "RaidRoom (type: " + type.getName() + ")";
}
}
} }

View File

@@ -29,8 +29,8 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Stub;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
import net.runelite.client.config.Stub;
@ConfigGroup("raids") @ConfigGroup("raids")
public interface RaidsConfig extends Config public interface RaidsConfig extends Config
@@ -185,32 +185,6 @@ public interface RaidsConfig extends Config
@ConfigItem( @ConfigItem(
position = 12, position = 12,
parent = "scouterConfig", parent = "scouterConfig",
keyName = "colorTightrope",
name = "Color tightrope",
description = "Colors tightrope a separate color"
)
default boolean colorTightrope()
{
return true;
}
@ConfigItem(
position = 13,
parent = "scouterConfig",
keyName = "tightropeColor",
name = "Tightrope color",
description = "The color of tightropes",
hidden = true,
unhide = "colorTightrope"
)
default Color tightropeColor()
{
return Color.MAGENTA;
}
@ConfigItem(
position = 14,
parent = "scouterConfig",
keyName = "layoutMessage", keyName = "layoutMessage",
name = "Send raid layout message when entering raid", name = "Send raid layout message when entering raid",
description = "Sends game message with raid layout on entering new raid" description = "Sends game message with raid layout on entering new raid"
@@ -224,16 +198,69 @@ public interface RaidsConfig extends Config
keyName = "roomConfig", keyName = "roomConfig",
name = "Room Config", name = "Room Config",
description = "", description = "",
position = 15 position = 13
) )
default Stub roomConfig() default Stub roomConfig()
{ {
return new Stub(); return new Stub();
} }
@ConfigItem(
position = 14,
parent = "roomConfig",
keyName = "colorTightrope",
name = "Color tightrope",
description = "Colors tightrope a separate color"
)
default boolean colorTightrope()
{
return true;
}
@ConfigItem(
position = 15,
parent = "roomConfig",
keyName = "tightropeColor",
name = "Tightrope color",
description = "The color of tightropes",
hidden = true,
unhide = "colorTightrope"
)
default Color tightropeColor()
{
return Color.MAGENTA;
}
@ConfigItem( @ConfigItem(
position = 16, position = 16,
parent = "roomConfig", parent = "roomConfig",
keyName = "crabHandler",
name = "Color crabs",
description = "If your crabs are good, it will color them to your set color." +
"<br> If they are bad crabs, it will be set to RED"
)
default boolean crabHandler()
{
return false;
}
@ConfigItem(
position = 17,
parent = "roomConfig",
keyName = "crabColor",
name = "Crab color",
description = "The color of good crabs",
hidden = true,
unhide = "crabHandler"
)
default Color crabColor()
{
return Color.MAGENTA;
}
@ConfigItem(
position = 18,
parent = "roomConfig",
keyName = "enableRotationWhitelist", keyName = "enableRotationWhitelist",
name = "Enable rotation whitelist", name = "Enable rotation whitelist",
description = "Enable the rotation whitelist" description = "Enable the rotation whitelist"
@@ -244,7 +271,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 17, position = 19,
parent = "roomConfig", parent = "roomConfig",
keyName = "whitelistedRotations", keyName = "whitelistedRotations",
name = "Whitelisted rotations", name = "Whitelisted rotations",
@@ -258,7 +285,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 18, position = 20,
parent = "roomConfig", parent = "roomConfig",
keyName = "enableLayoutWhitelist", keyName = "enableLayoutWhitelist",
name = "Enable layout whitelist", name = "Enable layout whitelist",
@@ -270,7 +297,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 19, position = 21,
parent = "roomConfig", parent = "roomConfig",
keyName = "whitelistedLayouts", keyName = "whitelistedLayouts",
name = "Whitelisted layouts", name = "Whitelisted layouts",
@@ -284,7 +311,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 20, position = 22,
parent = "roomConfig", parent = "roomConfig",
keyName = "showScavsFarms", keyName = "showScavsFarms",
name = "Show scavengers and farming", name = "Show scavengers and farming",
@@ -296,7 +323,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 21, position = 23,
parent = "roomConfig", parent = "roomConfig",
keyName = "scavsBeforeIce", keyName = "scavsBeforeIce",
name = "Show last scavs for Ice Demon", name = "Show last scavs for Ice Demon",
@@ -308,7 +335,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 22, position = 24,
parent = "roomConfig", parent = "roomConfig",
keyName = "scavsBeforeOlm", keyName = "scavsBeforeOlm",
name = "Show last scavs for Olm", name = "Show last scavs for Olm",
@@ -320,7 +347,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 23, position = 25,
parent = "roomConfig", parent = "roomConfig",
keyName = "scavPrepColor", keyName = "scavPrepColor",
name = "Last scavs color", name = "Last scavs color",
@@ -332,7 +359,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 24, position = 26,
parent = "roomConfig", parent = "roomConfig",
keyName = "whitelistedRooms", keyName = "whitelistedRooms",
name = "Whitelisted rooms", name = "Whitelisted rooms",
@@ -347,7 +374,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 25, position = 27,
parent = "roomConfig", parent = "roomConfig",
keyName = "blacklistedRooms", keyName = "blacklistedRooms",
name = "Blacklisted rooms", name = "Blacklisted rooms",
@@ -365,7 +392,7 @@ public interface RaidsConfig extends Config
keyName = "hideRooms", keyName = "hideRooms",
name = "Hide Rooms", name = "Hide Rooms",
description = "", description = "",
position = 26 position = 28
) )
default Stub hideRooms() default Stub hideRooms()
{ {
@@ -373,7 +400,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 27, position = 29,
parent = "hideRooms", parent = "hideRooms",
keyName = "hideRopeless", keyName = "hideRopeless",
name = "Hide no Tightrope raids", name = "Hide no Tightrope raids",
@@ -385,7 +412,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 28, position = 30,
parent = "hideRooms", parent = "hideRooms",
keyName = "hideVanguards", keyName = "hideVanguards",
name = "Hide Vanguard raids", name = "Hide Vanguard raids",
@@ -397,7 +424,7 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 29, position = 31,
parent = "hideRooms", parent = "hideRooms",
keyName = "hideUnknownCombat", keyName = "hideUnknownCombat",
name = "Hide Unknown combat raids", name = "Hide Unknown combat raids",
@@ -409,10 +436,10 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 30, position = 32,
keyName = "partyDisplay", keyName = "partyDisplay",
name = "Party Info Display", name = "Party Info Display",
description = "Display an overlay that shows information about the current party" description = "Display an overlay that shows information about the current party"
) )
default boolean partyDisplay() default boolean partyDisplay()
{ {
@@ -420,10 +447,10 @@ public interface RaidsConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "hotkey", keyName = "hotkey",
name = "Toggle scout overlay", name = "Toggle scout overlay",
description = "When pressed the scout overlay will be toggled. Must enable show scout overlay in raid", description = "When pressed the scout overlay will be toggled. Must enable show scout overlay in raid",
position = 31 position = 33
) )
default Keybind hotkey() default Keybind hotkey()
{ {

View File

@@ -25,6 +25,7 @@
*/ */
package net.runelite.client.plugins.raids; package net.runelite.client.plugins.raids;
import com.google.common.collect.ImmutableList;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@@ -34,6 +35,8 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -65,22 +68,56 @@ public class RaidsOverlay extends Overlay
private static final int BORDER_OFFSET = 2; private static final int BORDER_OFFSET = 2;
private static final int ICON_SIZE = 32; private static final int ICON_SIZE = 32;
private static final int SMALL_ICON_SIZE = 21; private static final int SMALL_ICON_SIZE = 21;
//might need to edit these if they are not standard
private static final int TITLE_COMPONENT_HEIGHT = 20; private static final int TITLE_COMPONENT_HEIGHT = 20;
private static final int LINE_COMPONENT_HEIGHT = 16; private static final int LINE_COMPONENT_HEIGHT = 16;
private static final Pattern FIRST_HALF = Pattern.compile("Start, (.*), End,");
private Client client; private static final Pattern SECOND_HALF = Pattern.compile(", Start, (.*), End");
private RaidsPlugin plugin; private static final ImmutableList<String> goodCrabsFirst = ImmutableList.of(
private RaidsConfig config; "FSCCP.PCSCF - #WNWSWN#ESEENW",
"SCFCP.CSCFS - #ENEESW#ENWWSW",
"SCFPC.CSPCF - #WSWWNE#WSEENE",
"SCPFC.CCPSF - #NWWWSE#WNEESE",
"SCPFC.CSPCF - #NEEESW#WWNEEE",
"SCSPF.CCSPF - #ESWWNW#ESENES",
"SPCFC.CSPCF - #WWNEEE#WSWNWS",
"SCPFC.PCSCF - #WNEEES#NWSWNW",
"SFCCPC.PCSCPF - #WSEENES#WWWNEEE",
"SCPFC.CCSSF - #NEESEN#WSWWNE"
);
private static final ImmutableList<String> goodCrabsSecond = ImmutableList.of(
"FSCCP.PCSCF - #WNWSWN#ESEENW",
"FSCCS.PCPSF - #WSEEEN#WSWNWS",
"FSCPC.CSCPF - #WNWWSE#EENWWW",
"SCFCP.CCSPF - #ESEENW#ESWWNW",
"SCFCP.CSCFS - #ENEESW#ENWWSW",
"SCFPC.CSPCF - #WSWWNE#WSEENE",
"SCFPC.PCCSF - #WSEENE#WWWSEE",
"SCFPC.SCPCF - #NESENE#WSWWNE",
"SCPFC.CCPSF - #NWWWSE#WNEESE",
"SCPFC.CSPCF - #NEEESW#WWNEEE",
"SCPFC.CSPSF - #WWSEEE#NWSWWN",
"SCSPF.CCSPF - #ESWWNW#ESENES",
"SFCCP.CSCPF - #WNEESE#NWSWWN",
"SFCCS.PCPSF - #ENWWSW#ENESEN",
"SPCFC.CSPCF - #WWNEEE#WSWNWS",
"SPCFC.SCCPF - #ESENES#WWWNEE",
"SPSFP.CCCSF - #NWSWWN#ESEENW",
"SFCCPC.PCSCPF - #WSEENES#WWWNEEE",
"FSCCP.PCSCF - #ENWWWS#NEESEN",
"SCPFC.CCSSF - #NEESEN#WSWWNE"
);
private final PanelComponent panelComponent = new PanelComponent(); private final PanelComponent panelComponent = new PanelComponent();
private final ItemManager itemManager; private final ItemManager itemManager;
private final SpriteManager spriteManager; private final SpriteManager spriteManager;
private final PanelComponent panelImages = new PanelComponent(); private final PanelComponent panelImages = new PanelComponent();
private Client client;
private RaidsPlugin plugin;
private RaidsConfig config;
@Setter @Setter
private boolean sharable = false; private boolean sharable = false;
@Getter @Setter @Getter
@Setter
private boolean scoutOverlayShown = false; private boolean scoutOverlayShown = false;
@Getter @Getter
@@ -145,6 +182,8 @@ public class RaidsOverlay extends Overlay
color = Color.RED; color = Color.RED;
} }
Matcher firstMatcher = FIRST_HALF.matcher(plugin.getRaid().getFullRotationString());
Matcher secondMatcher = SECOND_HALF.matcher(plugin.getRaid().getFullRotationString());
int combatCount = 0; int combatCount = 0;
int roomCount = 0; int roomCount = 0;
List<Integer> iceRooms = new ArrayList<>(); List<Integer> iceRooms = new ArrayList<>();
@@ -330,9 +369,22 @@ public class RaidsOverlay extends Overlay
{ {
color = config.tightropeColor(); color = config.tightropeColor();
} }
if (config.crabHandler() && puzzleNameLC.equals("crabs"))
{
if (firstMatcher.find() && secondMatcher.find())
{
if (crabHandler(firstMatcher.group(1), secondMatcher.group(1)))
{
color = config.crabColor();
}
else
{
color = Color.RED;
}
}
}
tableComponent.addRow(config.showRecommendedItems() ? "" : room.getType().getName(), ColorUtil.prependColorTag(puzzleName, color)); tableComponent.addRow(config.showRecommendedItems() ? "" : room.getType().getName(), ColorUtil.prependColorTag(puzzleName, color));
break; break;
case FARMING: case FARMING:
if (config.showScavsFarms()) if (config.showScavsFarms())
@@ -425,4 +477,19 @@ public class RaidsOverlay extends Overlay
} }
return ImageUtil.resizeCanvas(bim, SMALL_ICON_SIZE, SMALL_ICON_SIZE); return ImageUtil.resizeCanvas(bim, SMALL_ICON_SIZE, SMALL_ICON_SIZE);
} }
private boolean crabHandler(String firstHalf, String secondHalf)
{
if (firstHalf.contains("Crabs") && goodCrabsFirst.contains(plugin.getLayoutFullCode()))
{
return true;
}
if (secondHalf.contains("Crabs") && goodCrabsSecond.contains(plugin.getLayoutFullCode()))
{
return true;
}
return false;
}
} }

View File

@@ -39,7 +39,7 @@ import net.runelite.client.callback.ClientThread;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
public class RaidsPanel extends PluginPanel class RaidsPanel extends PluginPanel
{ {
@Inject @Inject
private Client client; private Client client;
@@ -95,10 +95,6 @@ public class RaidsPanel extends PluginPanel
throw new RuntimeException(f); throw new RuntimeException(f);
} }
} }
else
{
//TODO: User is still in a dc, or not logged in. Possibly provide a meaningful message somewhere.
}
}); });
reloadScouter.addActionListener((ActionEvent e) -> reloadScouter.addActionListener((ActionEvent e) ->
{ {

View File

@@ -24,22 +24,18 @@
*/ */
package net.runelite.client.plugins.raids; package net.runelite.client.plugins.raids;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Color;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import net.runelite.api.ClanMember;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.VarPlayer; import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.ClanMember;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayPriority;
@@ -50,18 +46,15 @@ import net.runelite.client.util.ColorUtil;
public class RaidsPartyOverlay extends Overlay public class RaidsPartyOverlay extends Overlay
{ {
public static final String PARTY_OVERLAY_RESET = "Reset missing"; static final String PARTY_OVERLAY_RESET = "Reset missing";
public static final String PARTY_OVERLAY_REFRESH = "Refresh party"; static final String PARTY_OVERLAY_REFRESH = "Refresh party";
private final PanelComponent panelComponent = new PanelComponent(); private final PanelComponent panelComponent = new PanelComponent();
private final PanelComponent panel = new PanelComponent();
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private RaidsPlugin plugin; private RaidsPlugin plugin;
private final PanelComponent panel = new PanelComponent();
@Inject @Inject
private RaidsPartyOverlay(RaidsPlugin plugin) private RaidsPartyOverlay(RaidsPlugin plugin)
{ {
@@ -97,7 +90,6 @@ public class RaidsPartyOverlay extends Overlay
tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
String partyCountString; String partyCountString;
Color countColor = Color.WHITE; Color countColor = Color.WHITE;

View File

@@ -34,8 +34,10 @@ import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -47,16 +49,16 @@ import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.InstanceTemplates; import net.runelite.api.InstanceTemplates;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.MenuAction;
import net.runelite.api.NullObjectID; import net.runelite.api.NullObjectID;
import static net.runelite.api.Perspective.SCENE_SIZE; import static net.runelite.api.Perspective.SCENE_SIZE;
import net.runelite.api.Point;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
import static net.runelite.api.SpriteID.TAB_QUESTS_BROWN_RAIDING_PARTY; import static net.runelite.api.SpriteID.TAB_QUESTS_BROWN_RAIDING_PARTY;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.VarPlayer; import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits; import net.runelite.api.Varbits;
import net.runelite.api.MenuAction;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ClientTick; import net.runelite.api.events.ClientTick;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
@@ -71,8 +73,8 @@ import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.game.ItemManager;
import net.runelite.client.events.OverlayMenuClicked; import net.runelite.client.events.OverlayMenuClicked;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -85,17 +87,15 @@ import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.DrawManager; import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.WidgetOverlay;
import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.WidgetOverlay;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.Tooltip;
import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.ui.overlay.tooltip.TooltipManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.HotkeyListener;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
import java.util.Set;
@PluginDescriptor( @PluginDescriptor(
name = "Chambers Of Xeric", name = "Chambers Of Xeric",
@@ -108,111 +108,101 @@ import java.util.Set;
@Slf4j @Slf4j
public class RaidsPlugin extends Plugin public class RaidsPlugin extends Plugin
{ {
static final DecimalFormat POINTS_FORMAT = new DecimalFormat("#,###");
private static final int LOBBY_PLANE = 3; private static final int LOBBY_PLANE = 3;
private static final String RAID_START_MESSAGE = "The raid has begun!"; private static final String RAID_START_MESSAGE = "The raid has begun!";
private static final String LEVEL_COMPLETE_MESSAGE = "level complete!"; private static final String LEVEL_COMPLETE_MESSAGE = "level complete!";
private static final String RAID_COMPLETE_MESSAGE = "Congratulations - your raid is complete!"; private static final String RAID_COMPLETE_MESSAGE = "Congratulations - your raid is complete!";
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###.##"); private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###.##");
static final DecimalFormat POINTS_FORMAT = new DecimalFormat("#,###");
private static final String SPLIT_REGEX = "\\s*,\\s*"; private static final String SPLIT_REGEX = "\\s*,\\s*";
private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)]"); private static final Pattern ROTATION_REGEX = Pattern.compile("\\[(.*?)]");
private static final int LINE_COMPONENT_HEIGHT = 16; private static final int LINE_COMPONENT_HEIGHT = 16;
@Inject
private ItemManager itemManager;
private static final Pattern LEVEL_COMPLETE_REGEX = Pattern.compile("(.+) level complete! Duration: ([0-9:]+)"); private static final Pattern LEVEL_COMPLETE_REGEX = Pattern.compile("(.+) level complete! Duration: ([0-9:]+)");
private static final Pattern RAID_COMPLETE_REGEX = Pattern.compile("Congratulations - your raid is complete! Duration: ([0-9:]+)"); private static final Pattern RAID_COMPLETE_REGEX = Pattern.compile("Congratulations - your raid is complete! Duration: ([0-9:]+)");
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private InfoBoxManager infoBoxManager;
@Inject
private Client client;
@Inject
private DrawManager drawManager;
@Inject
private ScheduledExecutorService executor;
@Inject
private RaidsConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private RaidsOverlay overlay;
@Inject
private RaidsPointsOverlay pointsOverlay;
@Inject
private RaidsPartyOverlay partyOverlay;
@Inject
private LayoutSolver layoutSolver;
@Inject
private KeyManager keyManager;
@Inject
private SpriteManager spriteManager;
@Inject
private ClientThread clientThread;
@Inject
private TooltipManager tooltipManager;
@Getter @Getter
private final ArrayList<String> roomWhitelist = new ArrayList<>(); private final ArrayList<String> roomWhitelist = new ArrayList<>();
@Getter @Getter
private final ArrayList<String> roomBlacklist = new ArrayList<>(); private final ArrayList<String> roomBlacklist = new ArrayList<>();
@Getter @Getter
private final ArrayList<String> rotationWhitelist = new ArrayList<>(); private final ArrayList<String> rotationWhitelist = new ArrayList<>();
@Getter @Getter
private final ArrayList<String> layoutWhitelist = new ArrayList<>(); private final ArrayList<String> layoutWhitelist = new ArrayList<>();
@Getter @Getter
private final Map<String, List<Integer>> recommendedItemsList = new HashMap<>(); private final Map<String, List<Integer>> recommendedItemsList = new HashMap<>();
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey())
{
@Override
public void hotkeyPressed()
{
if (config.scoutOverlayInRaid() && raidStarted)
{
if (overlay.isScoutOverlayShown())
{
overlay.setScoutOverlayShown(false);
}
else
{
overlay.setScoutOverlayShown(true);
}
}
}
};
public boolean canShow;
@Inject
private ChatMessageManager chatMessageManager;
@Inject
private InfoBoxManager infoBoxManager;
@Inject
private Client client;
@Inject
private DrawManager drawManager;
@Inject
private ScheduledExecutorService executor;
@Inject
private RaidsConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private RaidsOverlay overlay;
@Inject
private RaidsPointsOverlay pointsOverlay;
@Inject
private RaidsPartyOverlay partyOverlay;
@Inject
private LayoutSolver layoutSolver;
@Inject
private KeyManager keyManager;
@Inject
private SpriteManager spriteManager;
@Inject
private ClientThread clientThread;
@Inject
private TooltipManager tooltipManager;
@Getter @Getter
private Raid raid; private Raid raid;
@Getter @Getter
private boolean inRaidChambers; private boolean inRaidChambers;
@Inject @Inject
private ClientToolbar clientToolbar; private ClientToolbar clientToolbar;
private RaidsPanel panel;
private int upperTime = -1; private int upperTime = -1;
private int middleTime = -1; private int middleTime = -1;
private int lowerTime = -1; private int lowerTime = -1;
private int raidTime = -1; private int raidTime = -1;
private WidgetOverlay widgetOverlay; private WidgetOverlay widgetOverlay;
private String tooltip; private String tooltip;
public boolean canShow; @Inject
private ItemManager itemManager;
private NavigationButton navButton; private NavigationButton navButton;
private boolean raidStarted; private boolean raidStarted;
@Getter
private String layoutFullCode;
private RaidsTimer timer; private RaidsTimer timer;
@Getter @Getter
private int startPlayerCount; private int startPlayerCount;
@Getter @Getter
private List<String> partyMembers = new ArrayList<>(); private List<String> partyMembers = new ArrayList<>();
@Getter @Getter
private List<String> startingPartyMembers = new ArrayList<>(); private List<String> startingPartyMembers = new ArrayList<>();
@Getter @Getter
private Set<String> missingPartyMembers = new HashSet<>(); private Set<String> missingPartyMembers = new HashSet<>();
@@ -241,7 +231,7 @@ public class RaidsPlugin extends Plugin
updateLists(); updateLists();
clientThread.invokeLater(() -> checkRaidPresence(true)); clientThread.invokeLater(() -> checkRaidPresence(true));
widgetOverlay = overlayManager.getWidgetOverlay(WidgetInfo.RAIDS_POINTS_INFOBOX); widgetOverlay = overlayManager.getWidgetOverlay(WidgetInfo.RAIDS_POINTS_INFOBOX);
panel = injector.getInstance(RaidsPanel.class); RaidsPanel panel = injector.getInstance(RaidsPanel.class);
panel.init(config); panel.init(config);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "instancereloadhelper.png"); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "instancereloadhelper.png");
navButton = NavigationButton.builder() navButton = NavigationButton.builder()
@@ -485,13 +475,12 @@ public class RaidsPlugin extends Plugin
} }
} }
@Subscribe @Subscribe
public void onOverlayMenuClicked(OverlayMenuClicked event) public void onOverlayMenuClicked(OverlayMenuClicked event)
{ {
OverlayMenuEntry entry = event.getEntry(); OverlayMenuEntry entry = event.getEntry();
if (entry.getMenuAction() == MenuAction.RUNELITE_OVERLAY && if (entry.getMenuAction() == MenuAction.RUNELITE_OVERLAY &&
entry.getTarget().equals("Raids party overlay")) entry.getTarget().equals("Raids party overlay"))
{ {
switch (entry.getOption()) switch (entry.getOption())
{ {
@@ -573,7 +562,7 @@ public class RaidsPlugin extends Plugin
} }
} }
public void checkRaidPresence(boolean force) void checkRaidPresence(boolean force)
{ {
if (client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOGGED_IN)
{ {
@@ -605,6 +594,8 @@ public class RaidsPlugin extends Plugin
return; return;
} }
layoutFullCode = layout.getTest();
log.debug("Full Layout Code: " + layoutFullCode);
raid.updateLayout(layout); raid.updateLayout(layout);
RotationSolver.solve(raid.getCombatRooms()); RotationSolver.solve(raid.getCombatRooms());
overlay.setScoutOverlayShown(true); overlay.setScoutOverlayShown(true);
@@ -1073,23 +1064,4 @@ public class RaidsPlugin extends Plugin
tooltip = builder.toString(); tooltip = builder.toString();
} }
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey())
{
@Override
public void hotkeyPressed()
{
if (config.scoutOverlayInRaid() && raidStarted)
{
if (overlay.isScoutOverlayShown())
{
overlay.setScoutOverlayShown(false);
}
else
{
overlay.setScoutOverlayShown(true);
}
}
}
};
} }

View File

@@ -44,14 +44,6 @@ import net.runelite.client.ui.overlay.components.table.TableComponent;
public class RaidsPointsOverlay extends Overlay public class RaidsPointsOverlay extends Overlay
{ {
@Inject
private Client client;
@Inject
private RaidsPlugin plugin;
private final PanelComponent panel = new PanelComponent();
private static final NumberFormat UNIQUE_FORMAT = NumberFormat.getPercentInstance(Locale.ENGLISH); private static final NumberFormat UNIQUE_FORMAT = NumberFormat.getPercentInstance(Locale.ENGLISH);
static static
@@ -60,6 +52,12 @@ public class RaidsPointsOverlay extends Overlay
UNIQUE_FORMAT.setMinimumFractionDigits(2); UNIQUE_FORMAT.setMinimumFractionDigits(2);
} }
private final PanelComponent panel = new PanelComponent();
@Inject
private Client client;
@Inject
private RaidsPlugin plugin;
@Inject @Inject
private RaidsPointsOverlay(RaidsPlugin plugin) private RaidsPointsOverlay(RaidsPlugin plugin)
{ {
@@ -96,17 +94,6 @@ public class RaidsPointsOverlay extends Overlay
} }
tableComponent.addRow("Unique:", UNIQUE_FORMAT.format(uniqueChance)); tableComponent.addRow("Unique:", UNIQUE_FORMAT.format(uniqueChance));
//TODO this is annoyingly bugged, personalpoints returns null for some reason
/*
if (partySize > 1)
{
double personalChance = uniqueChance * (double)(personalPoints / totalPoints);
panel.getChildren().add(LineComponent.builder()
.left("Personal:")
.right(UNIQUE_FORMAT.format(personalChance))
.build());
}*/
panel.getChildren().add(tableComponent); panel.getChildren().add(tableComponent);

View File

@@ -47,7 +47,7 @@ public class RaidsTimer extends InfoBox
@Setter @Setter
private boolean stopped; private boolean stopped;
public RaidsTimer(BufferedImage image, Plugin plugin, Instant startTime) RaidsTimer(BufferedImage image, Plugin plugin, Instant startTime)
{ {
super(image, plugin); super(image, plugin);
this.startTime = startTime; this.startTime = startTime;
@@ -55,7 +55,7 @@ public class RaidsTimer extends InfoBox
stopped = false; stopped = false;
} }
public void timeFloor() void timeFloor()
{ {
Duration elapsed = Duration.between(floorTime, Instant.now()); Duration elapsed = Duration.between(floorTime, Instant.now());
@@ -75,45 +75,12 @@ public class RaidsTimer extends InfoBox
floorTime = Instant.now(); floorTime = Instant.now();
} }
public void timeOlm() void timeOlm()
{ {
Duration elapsed = Duration.between(floorTime, Instant.now()); Duration elapsed = Duration.between(floorTime, Instant.now());
olmTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); olmTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
} }
@Override
public String getText()
{
if (startTime == null)
{
return "";
}
if (!stopped)
{
Duration elapsed = Duration.between(startTime, Instant.now());
time = LocalTime.ofSecondOfDay(elapsed.getSeconds());
}
if (time.getHour() > 0)
{
return time.format(DateTimeFormatter.ofPattern("HH:mm"));
}
return time.format(DateTimeFormatter.ofPattern("mm:ss"));
}
@Override
public Color getTextColor()
{
if (stopped)
{
return Color.GREEN;
}
return Color.WHITE;
}
@Override @Override
public String getTooltip() public String getTooltip()
{ {
@@ -147,4 +114,37 @@ public class RaidsTimer extends InfoBox
return builder.toString(); return builder.toString();
} }
@Override
public String getText()
{
if (startTime == null)
{
return "";
}
if (!stopped)
{
Duration elapsed = Duration.between(startTime, Instant.now());
time = LocalTime.ofSecondOfDay(elapsed.getSeconds());
}
if (time.getHour() > 0)
{
return time.format(DateTimeFormatter.ofPattern("HH:mm"));
}
return time.format(DateTimeFormatter.ofPattern("mm:ss"));
}
@Override
public Color getTextColor()
{
if (stopped)
{
return Color.GREEN;
}
return Color.WHITE;
}
} }

View File

@@ -26,17 +26,14 @@ import net.runelite.client.ui.overlay.OverlayManager;
@Slf4j @Slf4j
public class ShortcutPlugin extends Plugin public class ShortcutPlugin extends Plugin
{ {
private final List<TileObject> shortcut = new ArrayList<>();
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject @Inject
private ShortcutOverlay overlay; private ShortcutOverlay overlay;
private final List<TileObject> shortcut = new ArrayList<>();
List<TileObject> getShortcut() List<TileObject> getShortcut()
{ {
return shortcut; return shortcut;

View File

@@ -27,12 +27,17 @@ package net.runelite.client.plugins.raids.solver;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
public class Layout public class Layout
{ {
@Getter @Getter
private final List<Room> rooms = new ArrayList<>(); private final List<Room> rooms = new ArrayList<>();
@Getter
@Setter
private String test;
public void add(Room room) public void add(Room room)
{ {
rooms.add(room); rooms.add(room);

View File

@@ -213,6 +213,7 @@ public class LayoutSolver
room.setPrevious(lastRoom); room.setPrevious(lastRoom);
lastRoom.setNext(room); lastRoom.setNext(room);
layout.add(room); layout.add(room);
layout.setTest(code);
position += 8; position += 8;
} }

View File

@@ -32,25 +32,6 @@ import net.runelite.client.plugins.raids.RaidRoom.Boss;
public class RotationSolver public class RotationSolver
{ {
private static class Rotation<E> extends ArrayList<E>
{
Rotation(Collection<? extends E> bosses)
{
super(bosses);
}
@Override
public E get(int index)
{
if (index < 0)
{
index = index + size();
}
return super.get(index % size());
}
}
private static final Rotation[] ROTATIONS = private static final Rotation[] ROTATIONS =
{ {
new Rotation<>(Arrays.asList(Boss.TEKTON, Boss.VASA, Boss.GUARDIANS, Boss.MYSTICS, Boss.SHAMANS, Boss.MUTTADILES, Boss.VANGUARDS, Boss.VESPULA)), new Rotation<>(Arrays.asList(Boss.TEKTON, Boss.VASA, Boss.GUARDIANS, Boss.MYSTICS, Boss.SHAMANS, Boss.MUTTADILES, Boss.VANGUARDS, Boss.VESPULA)),
@@ -147,4 +128,23 @@ public class RotationSolver
return true; return true;
} }
private static class Rotation<E> extends ArrayList<E>
{
Rotation(Collection<? extends E> bosses)
{
super(bosses);
}
@Override
public E get(int index)
{
if (index < 0)
{
index = index + size();
}
return super.get(index % size());
}
}
} }